UNPKG

1.12 kBJavaScriptView Raw
1import React from 'react';
2import ReactDOM from 'react-dom';
3import { BrowserRouter as Router } from "react-router-dom";
4import './index.css';
5import { Route, Switch } from 'react-router-dom';
6import asyncComponent from './AsyncComponent';
7const AsyncHomePage = asyncComponent(() => import('./HomePage'));
8const AsyncOtherPage = asyncComponent(() => import('./OtherPage'));
9const AsyncSimplePage = asyncComponent(() => import('./SimplePage'));
10
11const 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 {/* another-simple-page is another route to tests a page object with a path */}
33 <Route
34 path="/another-simple-page"
35 exact
36 component={AsyncSimplePage}
37 props={childProps}
38 />
39 </Switch>
40
41
42ReactDOM.render(<Router><Routes /></Router>, document.getElementById('root'));