Files
ontime/client/src/app/hooks/useFetch.js
T
cv f1face2592 rollback broadcastQueryClient
still trying to figure out why cache becomes undefined sometimes
2021-04-24 18:28:12 +02:00

12 lines
319 B
JavaScript

import { useQuery } from 'react-query';
const refetchIntervalMs = 10000;
export const useFetch = (namespace, fn) => {
const { data, status, isError, refetch } = useQuery(namespace, fn, {
refetchInterval: refetchIntervalMs,
cacheTime: refetchIntervalMs,
});
return { data, status, isError, refetch };
};