mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 17:03:53 +00:00
19 lines
443 B
JavaScript
19 lines
443 B
JavaScript
import { useQuery } from '@tanstack/react-query';
|
|
|
|
const refetchIntervalMs = 10000;
|
|
|
|
/**
|
|
* @description utility hook to simplify query config
|
|
* @param namespace
|
|
* @param fn
|
|
*/
|
|
export const useFetch = (namespace, fn) => {
|
|
const { data, status, isError, refetch } = useQuery(namespace, fn, {
|
|
refetchInterval: refetchIntervalMs,
|
|
cacheTime: Infinity,
|
|
networkMode: 'always',
|
|
});
|
|
|
|
return { data, status, isError, refetch };
|
|
};
|