0

Invariant Violation: NetInfo has been removed from React Native. It can now be installed and imported from 'react-native-netinfo' instead of 'react-native'

Getting the above error even after updating react-native-netinfo to react-native-community/netinfo. I have also changed the imports to import NetInfo from '@react-native-community/netinfo';

enter image description here

Ajay Sivan
  • 2,807
  • 2
  • 32
  • 57
  • 2
    perhaps one of your dependencies still imports it from `react-native`? – azundo Dec 05 '19 at 20:02
  • @azundo How can I fix it? – Ajay Sivan Dec 05 '19 at 20:06
  • If you expand the error stacktrace in the console you might be able to see the source file that the error is originating from which. Alternatively search your `node_modules` for `NetInfo` - (e.g. `cd node_modules && grep -R NetInfo .` on MacOS for example) to find the dependency that is using `NetInfo` from `react-native` then upgrade or remove it. – azundo Dec 05 '19 at 22:12

1 Answers1

1

Stop the packager, remove your node_modules folder, and reinstall the packages yarn install, and then restart the packager.

Francois Nadeau
  • 7,023
  • 2
  • 49
  • 58