ConceptPortal-public/rsconcept/frontend/src/main.tsx

52 lines
1.3 KiB
TypeScript
Raw Normal View History

import './index.css'
2023-07-25 20:27:29 +03:00
import React from 'react'
import { createRoot } from 'react-dom/client'
2023-07-25 20:27:29 +03:00
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';
2023-08-01 20:14:03 +03:00
import { LibraryState } from './context/LibraryContext.tsx';
import { ThemeState } from './context/ThemeContext.tsx';
import { UsersState } from './context/UsersContext.tsx';
2023-08-01 11:44:33 +03:00
import { initBackend } from './utils/backendAPI.ts';
2023-07-15 17:46:19 +03:00
2023-08-01 11:44:33 +03:00
initBackend();
2023-07-15 17:46:19 +03:00
const resetState = () => {
console.log('Resetting state after error fallback')
};
2023-10-16 01:39:17 +03:00
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-07-15 17:46:19 +03:00
};
createRoot(document.getElementById('root')!).render(
2023-07-15 17:46:19 +03:00
<React.StrictMode>
2023-07-25 20:27:29 +03:00
<ErrorBoundary
2023-07-15 17:46:19 +03:00
FallbackComponent={ErrorFallback}
onReset={resetState}
onError={logError}
>
<IntlProvider locale='ru' defaultLocale='ru'>
<ThemeState>
<UsersState>
2023-08-27 15:39:49 +03:00
<AuthState>
2023-08-01 20:14:03 +03:00
<LibraryState>
2023-07-15 17:46:19 +03:00
<App />
2023-08-01 20:14:03 +03:00
</LibraryState>
2023-07-15 17:46:19 +03:00
</AuthState>
2023-08-27 15:39:49 +03:00
</UsersState>
2023-07-15 17:46:19 +03:00
</ThemeState>
</IntlProvider>
</ErrorBoundary>
</React.StrictMode>,
)