Reputation: 51
I am trying to read the networkstatechange in react-native ios code as :
componentDidMound(){
NetInfo.isConnected.addEventListener('connectionChange',this._handleNetworkStateChange);
}
componentWillUnmount(){
NetInfo.isConnected.removeEventListener('connectionChange',this._handleNetworkStateChange);
}
_handleNetworkStateChange = (isConnected) => {
this.setState({
netStatus : isConnected
})
}
1)When nework is Active : while network state is changing from online to offline. App(ios) is directely crashing instead of reading state.
2)when network is inActive/offline initially : while changing network state from offline to online, it works properly. shows and loads the view perfectly.
any help would be appreciated as i have gone through many tutorials but not getting the solution.Thanks in advance.
Upvotes: 3
Views: 438