The create-react-native-library tool instantiates modules in JavaScript with code that looks like this:
import { NativeModules, Platform } from 'react-native';
const LINKING_ERROR =
`The package 'foo' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';
const Foo = NativeModules.Foo
? NativeModules.Foo
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);
If the module is not linked for some reason, this produces a nice error message. With the toolkit, the generated Typescript code simply tries to dereference the undefined module, which results in much less clear errors like:
Cannot read property 'unsubscribeFromToolkitUseFlow' of null
The
create-react-native-library
tool instantiates modules in JavaScript with code that looks like this:If the module is not linked for some reason, this produces a nice error message. With the toolkit, the generated Typescript code simply tries to dereference the undefined module, which results in much less clear errors like:
Cannot read property 'unsubscribeFromToolkitUseFlow' of null