Skip to content

Commit

Permalink
fix useNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Apr 8, 2024
1 parent fa0c505 commit 9fb92f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function useNetwork({onReconnect = () => {}}: UseNetworkProps = {
const callback = useRef(onReconnect);
callback.current = onReconnect;

const {isOffline} = useContext(NetworkContext) ?? CONST.DEFAULT_NETWORK_DATA;
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
Expand All @@ -29,5 +29,5 @@ export default function useNetwork({onReconnect = () => {}}: UseNetworkProps = {
prevOfflineStatusRef.current = isOffline;
}, [isOffline]);

return {isOffline: isOffline ?? false};
return {isOffline: networkStatus === CONST.NETWORK.NETWORK_STATUS.OFFLINE};
}

0 comments on commit 9fb92f1

Please sign in to comment.