|
1 | 1 | import React, { Component } from 'react';
|
2 | 2 | import { HashRouter, Route, Switch } from 'react-router-dom';
|
| 3 | +// import { renderRoutes } from 'react-router-config'; |
| 4 | +import Loadable from 'react-loadable'; |
3 | 5 | import './App.scss';
|
4 | 6 |
|
| 7 | +const loading = () => <div className="animated fadeIn pt-3 text-center">Loading...</div>; |
| 8 | + |
5 | 9 | // Containers
|
6 |
| -import { DefaultLayout } from './containers'; |
| 10 | +const DefaultLayout = Loadable({ |
| 11 | + loader: () => import('./containers/DefaultLayout'), |
| 12 | + loading |
| 13 | +}); |
| 14 | + |
7 | 15 | // Pages
|
8 |
| -import { Login, Page404, Page500, Register } from './views/Pages'; |
| 16 | +const Login = Loadable({ |
| 17 | + loader: () => import('./views/Pages/Login'), |
| 18 | + loading |
| 19 | +}); |
9 | 20 |
|
10 |
| -// import { renderRoutes } from 'react-router-config'; |
| 21 | +const Register = Loadable({ |
| 22 | + loader: () => import('./views/Pages/Register'), |
| 23 | + loading |
| 24 | +}); |
| 25 | + |
| 26 | +const Page404 = Loadable({ |
| 27 | + loader: () => import('./views/Pages/Page404'), |
| 28 | + loading |
| 29 | +}); |
| 30 | + |
| 31 | +const Page500 = Loadable({ |
| 32 | + loader: () => import('./views/Pages/Page500'), |
| 33 | + loading |
| 34 | +}); |
11 | 35 |
|
12 | 36 | class App extends Component {
|
| 37 | + |
13 | 38 | render() {
|
14 | 39 | return (
|
15 | 40 | <HashRouter>
|
16 |
| - <Switch> |
17 |
| - <Route exact path="/login" name="Login Page" component={Login} /> |
18 |
| - <Route exact path="/register" name="Register Page" component={Register} /> |
19 |
| - <Route exact path="/404" name="Page 404" component={Page404} /> |
20 |
| - <Route exact path="/500" name="Page 500" component={Page500} /> |
21 |
| - <Route path="/" name="Home" component={DefaultLayout} /> |
22 |
| - </Switch> |
| 41 | + <Switch> |
| 42 | + <Route exact path="/login" name="Login Page" component={Login} /> |
| 43 | + <Route exact path="/register" name="Register Page" component={Register} /> |
| 44 | + <Route exact path="/404" name="Page 404" component={Page404} /> |
| 45 | + <Route exact path="/500" name="Page 500" component={Page500} /> |
| 46 | + <Route path="/" name="Home" component={DefaultLayout} /> |
| 47 | + </Switch> |
23 | 48 | </HashRouter>
|
24 | 49 | );
|
25 | 50 | }
|
|
0 commit comments