This repository was archived by the owner on Oct 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path_app.tsx
49 lines (43 loc) · 1.57 KB
/
_app.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
import { AppProps } from 'next/app';
import { ThemeProvider, Theme, StyledEngineProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import theme from '../lib/theme';
import React, { useEffect } from 'react';
declare module '@mui/styles/defaultTheme' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface DefaultTheme extends Theme {}
}
// Determines if we are running on server or in client.
const isServerSideRendered = () => {
return typeof window === 'undefined';
};
/**
* Accessibility tool - outputs to devtools console on dev only and client-side only.
* @see https://github.com/dequelabs/axe-core-npm
*/
if (process.env.NODE_ENV !== 'production' && !isServerSideRendered()) {
import('react-dom').then((ReactDOM) => {
import('@axe-core/react').then((axe) => {
axe.default(React, ReactDOM, 1000, {});
});
});
}
const App = ({ Component, pageProps }: AppProps) => {
useEffect(() => {
// Remove the server-side injected CSS.
const jssStyles = document.querySelector('#jss-server-side');
if (jssStyles) {
jssStyles.parentElement?.removeChild(jssStyles);
}
}, []);
return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<Component {...pageProps} />
</ThemeProvider>
</StyledEngineProvider>
);
};
export default App;