1 | import React from 'react';
|
2 | import ReactDOM from 'react-dom';
|
3 | import { BrowserRouter as Router } from "react-router-dom";
|
4 | import './index.css';
|
5 | import { Route, Switch } from 'react-router-dom';
|
6 | import asyncComponent from './AsyncComponent';
|
7 | const AsyncHomePage = asyncComponent(() => import('./HomePage'));
|
8 | const AsyncOtherPage = asyncComponent(() => import('./OtherPage'));
|
9 | const AsyncSimplePage = asyncComponent(() => import('./SimplePage'));
|
10 |
|
11 | const Routes = ({ childProps }) =>
|
12 | <Switch>
|
13 | <Route
|
14 | path="/"
|
15 | exact
|
16 | component={AsyncHomePage}
|
17 | props={childProps}
|
18 | />
|
19 | <Route
|
20 | path="/other-page"
|
21 | exact
|
22 | component={AsyncOtherPage}
|
23 | props={childProps}
|
24 | />
|
25 | <Route
|
26 | path="/simple-page"
|
27 | exact
|
28 | component={AsyncSimplePage}
|
29 | props={childProps}
|
30 | />
|
31 |
|
32 | {}
|
33 | <Route
|
34 | path="/another-simple-page"
|
35 | exact
|
36 | component={AsyncSimplePage}
|
37 | props={childProps}
|
38 | />
|
39 | </Switch>
|
40 |
|
41 |
|
42 | ReactDOM.render(<Router><Routes /></Router>, document.getElementById('root'));
|