React Native Switching between different Wi-Fi network and NetInfo (Null SSID bug fixed)

March 02, 2022

React Native Switching between different Wi-Fi network and NetInfo (Null SSID bug fixed).

React Native Switching between different Wi-Fi network and NetInfo

 useEffect(() => {
    const subAppState = AppState.addEventListener("change", async (nextAppState) => {
      if (IS_IOS_DEVICE && nextAppState=='active') {
        let newNetInfo = await NativeModules.RNCNetInfo.getCurrentState('');
        console.log(newNetInfo);
      }
    });
    const unsubNetState = NetInfo.addEventListener(state => {
        console.log(state);
    });
    return () => {
        if (subAppState) {
            subAppState.remove();
        }
        unsubNetState();
    };
  },[]);

Written by Manoj Bhardwaj who lives and works in Dharamshala Himachal Pradesh (India). My stackoverflow