|
2 | 2 |
|
3 | 3 | // #region imports |
4 | 4 | import React from 'react'; |
| 5 | +import compose from 'recompose/compose'; |
| 6 | +import withSuspense from '../hoc/withSuspense'; |
5 | 7 | import { Route, Switch } from 'react-router'; |
6 | 8 | import PrivateRoute from '../components/privateRoute'; |
7 | 9 | // #endregion |
8 | 10 |
|
9 | 11 | // #region constants |
10 | 12 | const AsyncHome = React.lazy(() => import('../pages/home')); |
11 | | -// const AsyncAbout = React.lazy(() => import('../pages/about')); |
12 | | -// const AsyncProtected = React.lazy(() => import('../pages/protected')); |
13 | | -// const AsyncPageNotFound = React.lazy(() => import('../pages/pageNotFound')); |
| 13 | +const Home = compose(withSuspense())(AsyncHome); |
| 14 | + |
| 15 | +const AsyncAbout = React.lazy(() => import('../pages/about')); |
| 16 | +const About = compose(withSuspense())(AsyncAbout); |
| 17 | + |
| 18 | +const AsyncProtected = React.lazy(() => import('../pages/protected')); |
| 19 | +const Protected = compose(withSuspense())(AsyncProtected); |
| 20 | + |
| 21 | +const AsyncPageNotFound = React.lazy(() => import('../pages/pageNotFound')); |
| 22 | +const PageNotFound = compose(withSuspense())(AsyncPageNotFound); |
14 | 23 | // #endregion |
15 | 24 |
|
16 | 25 | const MainRoutes = () => { |
17 | 26 | return ( |
18 | 27 | <Switch> |
19 | 28 | {/* public views: */} |
20 | | - <Route exact path="/" component={AsyncHome} /> |
21 | | - {/* <Route path="/about" component={AsyncAbout} /> */} |
| 29 | + <Route exact path="/" component={Home} /> |
| 30 | + <Route path="/about" component={About} /> |
22 | 31 | {/* private views: need user to be authenticated */} |
23 | | - {/* <PrivateRoute path="/protected" component={AsyncProtected} /> */} |
24 | | - {/* <Route component={AsyncPageNotFound} /> */} |
| 32 | + <PrivateRoute path="/protected" component={Protected} /> |
| 33 | + <Route component={PageNotFound} /> |
25 | 34 | </Switch> |
26 | 35 | ); |
27 | 36 | }; |
|
0 commit comments