You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
342 B
18 lines
342 B
import useSWR from 'swr'; |
|
import fetcher from './fetchJSON'; |
|
|
|
const PeriodicFetch = <T>( |
|
url: string, |
|
refreshInterval = 5000, |
|
): GetResponses => { |
|
const { data, error } = useSWR<T>(url, fetcher, { |
|
refreshInterval, |
|
}); |
|
return { |
|
data, |
|
isLoading: !error && !data, |
|
isError: error, |
|
}; |
|
}; |
|
|
|
export default PeriodicFetch;
|
|
|