2023-07-26 23:11:00 +03:00
|
|
|
import './index.css'
|
2023-07-25 20:27:29 +03:00
|
|
|
|
2023-07-26 23:11:00 +03:00
|
|
|
import React from 'react'
|
2023-08-27 22:14:42 +03:00
|
|
|
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';
|
|
|
|
|
2023-07-26 23:11:00 +03:00
|
|
|
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';
|
2023-07-26 23:11:00 +03:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2023-08-27 22:14:42 +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>
|
2023-07-26 23:11:00 +03:00
|
|
|
</React.StrictMode>,
|
|
|
|
)
|