Skip to content

Commit

Permalink
feat: Throw an error if the native module is null with steps to help …
Browse files Browse the repository at this point in the history
…fix the issue (#33)
  • Loading branch information
matt-oakes committed Mar 22, 2019
1 parent 3924ff1 commit d3882c1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/nativeInterface.js
Expand Up @@ -12,6 +12,17 @@ import {NativeEventEmitter, NativeModules} from 'react-native';

const {RNCNetInfo} = NativeModules;

// Produce an error if we don't have the native module
if (!RNCNetInfo) {
throw new Error(`@react-native-community/netinfo: NativeModule.RNCNetInfo is null. To fix this issue try these steps:
• Run \`react-native link @react-native-community/netinfo\` in the project root.
• Rebuild and re-run the app.
• If you are using CocoaPods on iOS, run \`pod install\` in the \`ios\` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-netinfo`);
}

/**
* We export the native interface in this way to give easy shared access to it between the
* JavaScript code and the tests
Expand Down

0 comments on commit d3882c1

Please sign in to comment.