React native check if there is internet connection via listener
In your opinion this is the right approach: const [isNetwork, setIsNetwork] = useState(true); const [isChangeNetwork, setIsChangeNetwork] = useState(false); useEffect(() => { NetInfo.fetch().then(({ isConnected, isInternetReachable }) => setIsNetwork(isConnected && isInternetReachable) ); const unsubscribe = NetInfo.addEventListener( ({ isConnected, isInternetReachable }) => {…