-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tsx
62 lines (58 loc) · 1.61 KB
/
main.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { Button, ThemeProvider, createTheme } from '@mui/material';
import { red } from '@mui/material/colors';
import { ConfirmProvider } from 'material-ui-confirm';
import React from 'react';
import ReactDOM from 'react-dom/client';
import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
import { BrowserRouter } from 'react-router-dom';
import App from './App.tsx';
import { saveActivePrompt } from './common/saving/localstorage.ts';
import './index.css';
const theme = createTheme({
palette: {
mode: 'dark',
primary: {
main: red[500],
},
},
});
function fallbackRender({ error, resetErrorBoundary }: FallbackProps) {
const message =
error instanceof Error
? error.message
: JSON.stringify(error, undefined, 2);
function resetActivePrompt() {
saveActivePrompt('');
}
return (
<div className="text-red-600">
<h1>Oh No! Something went wrong!</h1>
<main>
<pre className="w-auto ">{message}</pre>
</main>
<div>
<Button variant="outlined" onClick={resetActivePrompt}>
Reset Active Prompt?
</Button>
</div>
<div>
<Button variant="outlined" onClick={resetErrorBoundary}>
Retry?
</Button>
</div>
</div>
);
}
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<ThemeProvider theme={theme}>
<BrowserRouter>
<ErrorBoundary fallbackRender={fallbackRender}>
<ConfirmProvider>
<App />
</ConfirmProvider>
</ErrorBoundary>
</BrowserRouter>
</ThemeProvider>
</React.StrictMode>,
);