I have updated react native version from 0.57 to 0.59.1. After successful updated it throws error in react native info, so i installed @react-native-community/netinfo and removed Netinfo from react-native.
I have run below commands to install latest version of netinfo:
npm install --save @react-native-community/netinfo
react-native link @react-native-community/netinfo
cd ios && pod install
After successful linking when run my project i got error @react-native-community/netinfo: NativeModule.RNCNetInfo is null...
I also tried with version 3 of netinfo but same error occurred.
Version:
@react-native-community/netinfo: ^5.3.2
react: ^16.8.3
react-native": ^0.59.1
Please help me if anyone have solution for this.
Thanks.
If you are getting this error while running jest test. Add following file to be used as a mock
source
add a mock for the NetInfo bridge module and you need not update the Jest config...
file location ==>
__mocks__/@react-native-community/netinfo.js
export default {
getCurrentConnectivity: jest.fn(),
isConnectionMetered: jest.fn(),
addListener: jest.fn(),
removeListeners: jest.fn(),
isConnected: {
fetch: () => {
return Promise.resolve(true);
},
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
},
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With