ConceptPortal-public/rsconcept/frontend/src/main.tsx
2023-08-27 22:14:42 +03:00

50 lines
1.3 KiB
TypeScript

import './index.css'
import React from 'react'
import { createRoot } from 'react-dom/client'
import { ErrorBoundary } from 'react-error-boundary';
import { IntlProvider } from 'react-intl';
import App from './App.tsx'
import ErrorFallback from './components/ErrorFallback.tsx';
import { AuthState } from './context/AuthContext.tsx';
import { LibraryState } from './context/LibraryContext.tsx';
import { ThemeState } from './context/ThemeContext.tsx';
import { UsersState } from './context/UsersContext.tsx';
import { initBackend } from './utils/backendAPI.ts';
initBackend();
const resetState = () => {
console.log('Resetting state after error fallback')
};
const logError = (error: Error, info: { componentStack: string }) => {
console.log('Error fallback: ' + error.message)
console.log('Component stack: ' + info.componentStack)
};
createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<ErrorBoundary
FallbackComponent={ErrorFallback}
onReset={resetState}
onError={logError}
>
<IntlProvider locale='ru' defaultLocale='ru'>
<ThemeState>
<UsersState>
<AuthState>
<LibraryState>
<App />
</LibraryState>
</AuthState>
</UsersState>
</ThemeState>
</IntlProvider>
</ErrorBoundary>
</React.StrictMode>,
)