NetInfo has been removed from react-native core. It should be installed as a stand alone dependency using following command:
yarn add @react-native-community/netinfo
or:
npm install --save @react-native-community/netinfo
step by step instructions can be found on this github link
I followed these steps mentioned on the above mentioned link , but it didn't resolve the issue completely. After digging the issue a little bit, I found out that in node_modules/react-native-meteor/src/Meteor.js ,
They are still importing NetInfo from 'react-native' and using the old functions
import { Platform, View, NetInfo } from 'react-native';
NetInfo.isConnected.fetch().then(
(connected ) => {
if(connected)
NetInfo.isConnected.addEventListener('connectionChange', isConnected => {
if (isConnected && Data.ddp.autoReconnect) {
Data.ddp.connect();
}
});
}
);
which is obsoleted now.
It has to be imported from @react-native-community/netinfo
After doing the following changes in node_modules/react-native-meteor/src/Meteor.js .
Error fixed:
import { Platform, View } from 'react-native';
import NetInfo from "@react-native-community/netinfo";
NetInfo.fetch().then(state => {
console.log("Connection type", state.type);
console.log("Is connected?", state.isConnected);
let isConnected = state.isConnected;
if(isConnected)
NetInfo.isConnected.addEventListener('connectionChange', isConnected => {
if (isConnected && Data.ddp.autoReconnect) {
Data.ddp.connect();
}
});
});