-
Notifications
You must be signed in to change notification settings - Fork 0
/
_app.tsx
57 lines (52 loc) · 1.74 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
50
51
52
53
54
55
56
57
import { useEffect, useMemo, Fragment, ReactElement, FC } from 'react';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import Head from 'next/head';
import { AppProps } from 'next/app';
import { ThemeProvider } from '@material-ui/core/styles';
import { createMuiTheme } from '@material-ui/core/styles';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import { store, persistor } from '../lib/store';
import palette from '../styles/palette';
const MiniBlog: FC<AppProps> = (props: AppProps): ReactElement => {
const { Component, pageProps } = props;
useEffect(() => {
// Remove the server-side injected CSS.
const jssStyles = document.querySelector('#jss-server-side');
if (jssStyles) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
jssStyles.parentElement!.removeChild(jssStyles);
}
}, []);
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
const theme = useMemo(
() =>
createMuiTheme({
palette: {
type: prefersDarkMode ? 'dark' : 'light',
...palette,
},
}),
[prefersDarkMode]
);
return (
<Fragment>
<Head>
<title>Reddit reader!</title>
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width"
/>
</Head>
<Provider store={store}>
<PersistGate persistor={persistor}>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<Component {...pageProps} />
</ThemeProvider>
</PersistGate>
</Provider>
</Fragment>
);
};
export default MiniBlog;