Fixed React Query provider. Removed getSession and replaced with getUser to make Supabase happy. Fixed Stepper's responsiveness.

This commit is contained in:
giancarlo
2024-06-03 16:13:55 +07:00
parent 88cebc2126
commit b1c3f12721
5 changed files with 7748 additions and 6090 deletions

View File

@@ -1,21 +1,23 @@
'use client';
import { useState } from 'react';
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) {
const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: {
queries: {
// With SSR, we usually want to set some default staleTime
// above 0 to avoid refetching immediately on the client
staleTime: 60 * 1000,
},
},
}),
);
return (
<QueryClientProvider client={queryClient}>
{props.children}