react-native-netinfo icon indicating copy to clipboard operation
react-native-netinfo copied to clipboard

React Native's NetInfo different behaviour on iOS and Android

Open faizanbuggy opened this issue 4 years ago • 2 comments

Hi All, 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 (Is it, that on android the previous state i.e false is replaced with true abruptly ?). Please help in this

faizanbuggy avatar Aug 31 '21 15:08 faizanbuggy

Hi there! With apologies, this app is largely supported by the community - what that means specifically is that you'll need to dig into the code and try for a fix here, or collaborate with a colleague to do the same. I will happily review and merge and release PRs but given you have the reproduction scenario all set up for testing you'll be best suited to develop the fix

mikehardy avatar Aug 31 '21 16:08 mikehardy

Hey! I know this app is largely supported by the community. So, if anyone wants to help me with this he is welcome. Thanks!

faizanbuggy avatar Sep 02 '21 11:09 faizanbuggy