I am using NetInfo from @react-native-community/netinfo My UseEffect Code is:
useEffect(() => {
const checkNet = NetInfo.addEventListener((state) => {
if(!state.isConnected){
setShowModal("internet")
}
console.log("state at splash",state.isConnected);
});
return () => {
checkNet();
};
}, []);
Then an Alert is shown to Reload the app and the following function is called
const reCheckNet = async() => {
const data = await NetInfo.fetch();
if(data.isConnected){
NetInfo.addEventListener((state) => {
if(state.isConnected){
setShowModal("")
RNRestart.Restart()
}
else
setShowModal("internet")
});
}
}
The pattern I am testing is: I turn off the wifi and open the app, it shows me the alert (which is good) but if I close the alert and turn on the wifi, the alert is only shown on iOS but not on Android. Please help in this