diff --git a/src/hooks/useNetwork.ts b/src/hooks/useNetwork.ts index 778fed200b7b..950d0592b59c 100644 --- a/src/hooks/useNetwork.ts +++ b/src/hooks/useNetwork.ts @@ -12,8 +12,7 @@ export default function useNetwork({onReconnect = () => {}}: UseNetworkProps = { const callback = useRef(onReconnect); callback.current = onReconnect; - const {networkStatus} = useContext(NetworkContext) ?? {...CONST.DEFAULT_NETWORK_DATA, networkStatus: CONST.NETWORK.NETWORK_STATUS.UNKNOWN}; - const isOffline = networkStatus === CONST.NETWORK.NETWORK_STATUS.OFFLINE; + const {isOffline, networkStatus} = useContext(NetworkContext) ?? {...CONST.DEFAULT_NETWORK_DATA, networkStatus: CONST.NETWORK.NETWORK_STATUS.UNKNOWN}; const prevOfflineStatusRef = useRef(isOffline); useEffect(() => { // If we were offline before and now we are not offline then we just reconnected @@ -30,5 +29,6 @@ export default function useNetwork({onReconnect = () => {}}: UseNetworkProps = { prevOfflineStatusRef.current = isOffline; }, [isOffline]); - return {isOffline}; + // If the network status is undefined, we don't treat it as offline. Otherwise, we utilize the isOffline prop. + return {isOffline: networkStatus === CONST.NETWORK.NETWORK_STATUS.UNKNOWN ? false : isOffline}; }