ConceptPortal-public/rsconcept/frontend/src/app/GlobalProviders.tsx

43 lines
1.1 KiB
TypeScript
Raw Normal View History

'use client';
import { QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { ErrorBoundary } from 'react-error-boundary';
import { IntlProvider } from 'react-intl';
import { queryClient } from '@/backend/queryClient';
import ErrorFallback from './ErrorFallback';
const resetState = () => {
2023-12-28 14:04:44 +03:00
console.log('Resetting state after error fallback');
};
const logError = (error: Error, info: { componentStack?: string | null | undefined }) => {
console.log('Error fallback: ' + error.message);
if (info.componentStack) {
console.log('Component stack: ' + info.componentStack);
}
};
2023-12-28 14:04:44 +03:00
// prettier-ignore
2024-09-19 17:49:25 +03:00
function GlobalProviders({ children }: React.PropsWithChildren) {
return (
<ErrorBoundary
FallbackComponent={ErrorFallback}
onReset={resetState}
onError={logError}
>
<IntlProvider locale='ru' defaultLocale='ru'>
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
{children}
</QueryClientProvider>
</IntlProvider>
</ErrorBoundary>);
}
2023-12-28 14:04:44 +03:00
export default GlobalProviders;