We are using react-native NetInfo in following way.
export default class NetworkStatus extends React.PureComponent {
constructor(props){
super(props);
NetInfo.addEventListener(
'change',
this.onConnectivityChange
);
}
onConnectivityChange = (status) => {
NetInfo.isConnected.fetch().then(isConnected => {
console.log('*********Network status ' + (isConnected ? 'online' :
'offline'));
});
}
Launched the app in Offline Mode. We got the following console.
*********Network status offline.
Then we turned on wifi and it is connected. But we got offline console twice.
*********Network status offline.
*********Network status offline.
Is this a bug in NetInfo Library. Is there a way to fix it.
versions used :
"react": "16.0.0-alpha.6"
"react-native": "0.44.0",