We use adaptive NetInfo as follows.
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 application offline. We have the following console.
********* Offline network status.
Then we turned on wifi and connected. But twice we got a standalone console.
********* Offline network status.
********* Offline network status.
Is this a bug in the NetInfo library. Is there any way to fix this.
Used Versions:
"respond": "16.0.0-alpha.6"
"react-native": "0.44.0",
source
share