bigbuffet-rw/packages/pl-hooks/lib/contexts/query-client.ts
marcin mikołajczak 9aa8ded6c6 Make pl-hooks self-containted
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-17 21:08:50 +02:00

21 lines
597 B
TypeScript

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 };