bigbuffet-rw/packages/pl-hooks/lib/contexts/query-client.ts

22 lines
597 B
TypeScript
Raw Normal View History

import { QueryClient } from '@tanstack/react-query';
import React from 'react';
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
staleTime: 60000, // 1 minute
gcTime: Infinity,
retry: false,
},
},
});
const PlHooksQueryClientContext = React.createContext<QueryClient>(queryClient);
const PlHooksQueryClientProvider = PlHooksQueryClientContext.Provider;
const usePlHooksQueryClient = () => React.useContext(PlHooksQueryClientContext);
export { queryClient, PlHooksQueryClientProvider, usePlHooksQueryClient };