feat: revue de code, doc CODE_REVIEW, forfaits 2026, traduction LLM, providers avec modèle
Made-with: Cursor
This commit is contained in:
38
frontend/src/providers/QueryProvider.tsx
Normal file
38
frontend/src/providers/QueryProvider.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
'use client';
|
||||
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { useState, type ReactNode, useCallback } from 'react';
|
||||
|
||||
const DEFAULT_STALE_TIME_MS = 60 * 1000;
|
||||
|
||||
export function QueryProvider({ children }: { children: ReactNode }) {
|
||||
const [queryClient] = useState(
|
||||
() =>
|
||||
new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: DEFAULT_STALE_TIME_MS,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false,
|
||||
},
|
||||
mutations: {
|
||||
retry: 1,
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
const handleGlobalError = useCallback((error: unknown) => {
|
||||
if (typeof window !== 'undefined') {
|
||||
console.error('[QueryClient Error]', error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{children}
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export { DEFAULT_STALE_TIME_MS };
|
||||
Reference in New Issue
Block a user