|
1 | 1 | import './assets/styles/base.scss'; |
2 | 2 | import { Route, Routes } from 'react-router-dom'; |
| 3 | +import { Suspense, lazy } from 'react'; |
3 | 4 | import Header from './components/layout/Header/Header'; |
4 | | -import RecipientList from './pages/RecipientList/RecipientList'; |
5 | | -import Home from './pages/Home/Home'; |
6 | | -import CreateRecipient from './pages/CreateRecipient/CreateRecipient'; |
7 | | -import Recipient from './pages/Recipient/Recipient'; |
8 | | -import MessageForm from './pages/MessageForm/MessageForm'; |
| 5 | + |
| 6 | +const RecipientList = lazy(() => import('./pages/RecipientList/RecipientList')); |
| 7 | +const Home = lazy(() => import('./pages/Home/Home')); |
| 8 | +const CreateRecipient = lazy( |
| 9 | + () => import('./pages/CreateRecipient/CreateRecipient'), |
| 10 | +); |
| 11 | +const Recipient = lazy(() => import('./pages/Recipient/Recipient')); |
| 12 | +const MessageForm = lazy(() => import('./pages/MessageForm/MessageForm')); |
9 | 13 |
|
10 | 14 | export default function App() { |
11 | 15 | return ( |
12 | 16 | <> |
13 | 17 | <Header /> |
14 | | - <Routes> |
15 | | - <Route path="/" element={<Home />} /> |
16 | | - <Route path="/list" element={<RecipientList />} /> |
17 | | - <Route path="/post" element={<CreateRecipient />} /> |
18 | | - <Route path="/post/:id" element={<Recipient showDelete={false} />} /> |
19 | | - <Route |
20 | | - path="/post/:id/edit" |
21 | | - element={<Recipient showDelete={true} />} |
22 | | - /> |
23 | | - <Route path="/post/:id/message" element={<MessageForm />} /> |
24 | | - </Routes> |
| 18 | + <Suspense fallback={<div>로딩중...</div>}> |
| 19 | + <Routes> |
| 20 | + <Route path="/" element={<Home />} /> |
| 21 | + <Route path="/list" element={<RecipientList />} /> |
| 22 | + <Route path="/post" element={<CreateRecipient />} /> |
| 23 | + <Route path="/post/:id" element={<Recipient showDelete={false} />} /> |
| 24 | + <Route |
| 25 | + path="/post/:id/edit" |
| 26 | + element={<Recipient showDelete={true} />} |
| 27 | + /> |
| 28 | + <Route path="/post/:id/message" element={<MessageForm />} /> |
| 29 | + </Routes> |
| 30 | + </Suspense> |
25 | 31 | </> |
26 | 32 | ); |
27 | 33 | } |
0 commit comments