Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Improve linking error output #58

Open
rocketraman opened this issue Apr 26, 2024 · 0 comments · May be fixed by #61
Open

[Feature] Improve linking error output #58

rocketraman opened this issue Apr 26, 2024 · 0 comments · May be fixed by #61
Assignees
Labels
enhancement New feature or request

Comments

@rocketraman
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants