Improved cache invalidation, and minor design fixes
This commit is contained in:
24
apps/web/components/react-query-provider.tsx
Normal file
24
apps/web/components/react-query-provider.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
|
||||
// set gcTime to 0 on the server
|
||||
// as we cannot invalidate the cache on the server
|
||||
const isServer = typeof document === 'undefined';
|
||||
const gcTime = isServer ? 0 : undefined;
|
||||
const staleTime = isServer ? 0 : 60 * 1000;
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
gcTime,
|
||||
staleTime,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export function ReactQueryProvider(props: React.PropsWithChildren) {
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{props.children}
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user