-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
49 lines (38 loc) · 1.23 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 { Suspense, lazy, useEffect } from 'react';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import { PATH } from './utils/path';
import Loader from '@/components/common/Loader';
const MainPage = lazy(() => import('@/pages/main'));
const SelectApplyMode = lazy(() => import('@/pages/locker-mode'));
const ApplyPage = lazy(() => import('@/pages/locker-mode/apply'));
function setScreenSize() {
const vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
}
function App() {
useEffect(() => {
setScreenSize();
}, []);
useEffect(() => {
const onResize = () => {
setScreenSize();
};
window.addEventListener('resize', onResize);
return () => {
window.removeEventListener('resize', onResize);
};
}, []);
return (
<BrowserRouter basename='/client'>
<Suspense fallback={<Loader />}>
<Routes>
<Route path={PATH.MAIN} element={<MainPage />} />
<Route path={PATH.LOCKER} element={<SelectApplyMode />} />
<Route path={PATH.APPLY} element={<ApplyPage />} />
<Route path={PATH.NOTICE} element={<MainPage />} />
</Routes>
</Suspense>
</BrowserRouter>
);
}
export default App;