improvements in react-query

- fetch to useFetch hook
- refetch every 10s
- sync browser tabs with experimental broadcastQueryClient
This commit is contained in:
cv
2021-04-24 15:05:18 +02:00
parent e8bca40653
commit 3f8c6f1192
6 changed files with 32 additions and 15 deletions
+10
View File
@@ -0,0 +1,10 @@
import { useQuery } from 'react-query';
const refetchIntervalMs = 10000;
export const useFetch = (namespace, fn) => {
const { data, status, isError, refetch } = useQuery(namespace, fn, {
refetchInterval: refetchIntervalMs,
});
return { data, status, isError, refetch };
};