Browse Source
Merge pull request #486 from HeroProtagonist/code-split-example-edit
Properly nest components in router
main
Alex
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
10 additions and
8 deletions
-
content/docs/code-splitting.md
|
|
@ -167,7 +167,7 @@ libraries like [React Router](https://reacttraining.com/react-router/) and |
|
|
|
[React Loadable](https://github.com/thejameskyle/react-loadable). |
|
|
|
|
|
|
|
```js |
|
|
|
import { BrowserRouter as Router, Route } from 'react-router-dom'; |
|
|
|
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; |
|
|
|
import Loadable from 'react-loadable'; |
|
|
|
|
|
|
|
const Loading = () => <div>Loading...</div>; |
|
|
@ -184,8 +184,10 @@ const About = Loadable({ |
|
|
|
|
|
|
|
const App = () => ( |
|
|
|
<Router> |
|
|
|
<Switch> |
|
|
|
<Route exact path="/" component={Home}/> |
|
|
|
<Route path="/about" component={About}/> |
|
|
|
</Switch> |
|
|
|
</Router> |
|
|
|
); |
|
|
|
``` |
|
|
|