Skip to content

Commit 8199087

Browse files
committed
[facebook#641] adds recipe for adding React Router (v4)
1 parent c6428ea commit 8199087

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast
110110
- [Adding Images and Fonts](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-images-and-fonts)
111111
- [Using the `public` Folder](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-the-public-folder)
112112
- [Adding Bootstrap](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-bootstrap)
113+
- [Adding React Router](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-react-router)
113114
- [Adding Flow](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-flow)
114115
- [Adding Custom Environment Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables)
115116
- [Can I Use Decorators?](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#can-i-use-decorators)

Diff for: packages/react-scripts/template/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
2121
- [Adding Images and Fonts](#adding-images-and-fonts)
2222
- [Using the `public` Folder](#using-the-public-folder)
2323
- [Adding Bootstrap](#adding-bootstrap)
24+
- [Adding React Router](#adding-react-router)
2425
- [Adding Flow](#adding-flow)
2526
- [Adding Custom Environment Variables](#adding-custom-environment-variables)
2627
- [Can I Use Decorators?](#can-i-use-decorators)
@@ -409,6 +410,18 @@ import { Navbar, Jumbotron, Button } from 'react-bootstrap';
409410

410411
Now you are ready to use the imported React Bootstrap components within your component hierarchy defined in the render method. Here is an example [`App.js`](https://gist.githubusercontent.com/gaearon/85d8c067f6af1e56277c82d19fd4da7b/raw/6158dd991b67284e9fc8d70b9d973efe87659d72/App.js) redone using React Bootstrap.
411412

413+
## Adding React Router
414+
415+
React Router is a popular solution for adding routing capabilities to your single-page applications. If your app needs routing, you can configure React Router to work with Create React app by following these steps:
416+
417+
Install React Router v4 from NPM. _note: we are installing a pre-release version of React Router as of the time of this writing, but it functions very well for many needs._
418+
419+
```
420+
npm install react-router@next --save
421+
```
422+
423+
You can run the [basic React Router example](https://react-router.now.sh/basic) by replacing the contents of `src/App.js` with the example code they provide. Most of the documented React Router examples should function in this way.
424+
412425
## Adding Flow
413426

414427
Flow typing is currently [not supported out of the box](https://github.com/facebookincubator/create-react-app/issues/72) with the default `.flowconfig` generated by Flow. If you run it, you might get errors like this:

0 commit comments

Comments
 (0)