forked from amand33p/bug-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
43 lines (37 loc) · 1.26 KB
/
Copy pathApp.tsx
File metadata and controls
43 lines (37 loc) · 1.26 KB
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
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { autoLogin } from './redux/slices/authSlice';
import { selectThemeState, toggleDarkMode } from './redux/slices/themeSlice';
import NavBar from './components/NavBar';
import Routes from './Routes';
import ToastNotification from './components/ToastNotification';
import storage from './utils/localStorage';
import customTheme from './styles/customTheme';
import { useBodyStyles } from './styles/muiStyles';
import { ThemeProvider } from '@material-ui/core/styles';
const App = () => {
const dispatch = useDispatch();
const { darkMode } = useSelector(selectThemeState);
const classes = useBodyStyles(darkMode)();
useEffect(() => {
dispatch(autoLogin());
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
const loadedDarkMode = storage.loadDarkMode();
if (loadedDarkMode && !darkMode) {
dispatch(toggleDarkMode());
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<ThemeProvider theme={customTheme(darkMode)}>
<div className={classes.root}>
<NavBar />
<Routes />
<ToastNotification />
</div>
</ThemeProvider>
);
};
export default App;