mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 08:34:52 -07:00
refactor redux data model
This commit is contained in:
parent
ae1bc3da38
commit
0ff391491d
243 changed files with 5212 additions and 5963 deletions
|
|
@ -2,26 +2,43 @@
|
|||
// creates the Redux store or connects to Redux DevTools.
|
||||
import './polyfills';
|
||||
|
||||
import { StrictMode } from 'react';
|
||||
import { StrictMode, useRef } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { StyledEngineProvider } from '@mui/material';
|
||||
import { ThemeProvider } from '@mui/material/styles';
|
||||
|
||||
import { WebClient } from '@app/websocket';
|
||||
import { createWebClientResponse, createWebClientRequest } from '@app/api';
|
||||
import { AppShell } from '@app/containers';
|
||||
import { materialTheme } from './material-theme';
|
||||
|
||||
import './i18n';
|
||||
import './index.css';
|
||||
|
||||
const AppWithMaterialTheme = () => (
|
||||
<StrictMode>
|
||||
<StyledEngineProvider injectFirst>
|
||||
<ThemeProvider theme={materialTheme}>
|
||||
<AppShell />
|
||||
</ThemeProvider>
|
||||
</StyledEngineProvider>
|
||||
</StrictMode>
|
||||
);
|
||||
function initWebClient() {
|
||||
const initialized = useRef(false);
|
||||
|
||||
if (!initialized.current) {
|
||||
initialized.current = true;
|
||||
new WebClient(createWebClientResponse(), createWebClientRequest());
|
||||
}
|
||||
}
|
||||
|
||||
const AppWithMaterialTheme = () => {
|
||||
// Instantiate the WebClient singleton before any container renders or any
|
||||
// hook touches WebClient.instance.
|
||||
initWebClient();
|
||||
|
||||
return (
|
||||
<StrictMode>
|
||||
<StyledEngineProvider injectFirst>
|
||||
<ThemeProvider theme={materialTheme}>
|
||||
<AppShell />
|
||||
</ThemeProvider>
|
||||
</StyledEngineProvider>
|
||||
</StrictMode>
|
||||
);
|
||||
}
|
||||
|
||||
const container = document.getElementById('root');
|
||||
const root = createRoot(container!);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue