import { useQuery } from 'react-query' ; import { fetchWithTimeout } from '@app/common/api/wrapped-fetch' ; const STALE_TIME = 15 * 60 * 1000 ; const networkStatusQueryOptions = { keepPreviousData : true , cacheTime : STALE_TIME , refetchOnMount : false , refetchInterval : false , refetchOnReconnect : false , } as const ; function getNetworkStatusFetcher ( url ) { return fetchWithTimeout ( url , { timeout : 4500 } ) ; } export function useGetNetworkStatus ( url ) { return useQuery ( { queryKey : [ 'network-status' , url ] , queryFn : ( ) => getNetworkStatusFetcher ( url ) , ... networkStatusQueryOptions , } ) ; }