-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRouter.tsx
26 lines (23 loc) · 826 Bytes
/
Router.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
import { Spinner } from '@chakra-ui/react';
import { FC, lazy, Suspense } from 'react';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
const MainLayout = lazy(() => import('@/layouts/MainLayout'));
const StarShipList = lazy(() => import('@/pages/StarShipList'));
const Favorites = lazy(() => import('@/pages/Favorites'));
const NotFound = lazy(() => import('@/pages/NotFound'));
const Router: FC = () => {
return (
<BrowserRouter>
<Suspense fallback={<Spinner />}>
<MainLayout>
<Routes>
<Route path="/" element={<StarShipList />} />
<Route path="/favorites" element={<Favorites />} />
<Route path="*" element={<NotFound />} />
</Routes>
</MainLayout>
</Suspense>
</BrowserRouter>
);
};
export default Router;