Improved cache invalidation, and minor design fixes

This commit is contained in:
giancarlo
2024-06-03 15:10:40 +07:00
parent d0c6981e78
commit 88cebc2126
10 changed files with 7655 additions and 9714 deletions

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