Skip to content

Commit 84e99a1

Browse files
committed
migrated router doc
1 parent cc907b8 commit 84e99a1

File tree

4 files changed

+86
-224
lines changed

4 files changed

+86
-224
lines changed

doc/02 Components/0 Router.md

Lines changed: 0 additions & 214 deletions
This file was deleted.

docs/README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
## Table of Contents
22

3-
- [Introduction](Introduction.md)
4-
- [Route Configuration](RouteConfiguration.md)
5-
- [Route Matching](RouteMatching.md)
6-
- [Dynamic Routing](DynamicRouting.md)
7-
- [Confirming Navigation](ConfirmingNavigation.md)
8-
- [Server Rendering](Server Rendering.md)
93
- [Glossary](Glossary.md)
10-
- [Route](Route.md)
11-
- [Plain Route](Plain Route.md)
12-
- [Redirect](Redirect.md)
4+
- Guides
5+
- [Introduction](Introduction.md)
6+
- [Route Configuration](RouteConfiguration.md)
7+
- [Route Matching](RouteMatching.md)
8+
- [Dynamic Routing](DynamicRouting.md)
9+
- [Confirming Navigation](ConfirmingNavigation.md)
10+
- [Server Rendering](Server Rendering.md)
11+
- API
12+
- [Router](Route.md)
13+
- [Route](Route.md)
14+
- [Plain Route](Plain Route.md)
15+
- [Redirect](Redirect.md)
1316

1417
- [Server Rendering](ServerRendering.md)

docs/Router.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
Primary component of React Router. It keeps your UI and the URL in sync.
2+
3+
## Props
4+
-----
5+
6+
#### `children` (required)
7+
8+
One or many [`Routes`][Route] or [Plain Routes][PlainRoute]. When the
9+
history changes, `Router` will match a branch of its [`Routes`][Route],
10+
and render their configured [components][RouteComponent], with child
11+
route components nested inside the parents.
12+
13+
#### `routes`
14+
15+
Alias for `children`.
16+
17+
#### `history`
18+
19+
The history the router should listen to from the `history` package.
20+
21+
#### `createElement(Component, props)`
22+
23+
When the router is ready to render a branch of route components, it will
24+
use this function to create the elements. You may want to take control
25+
of creating the elements when you're using some sort of data
26+
abstraction, like setting up subscriptions to stores, or passing in some
27+
sort of application module to each component via props.
28+
29+
##### Examples
30+
31+
```js
32+
<Router createElement={createElement}/>
33+
34+
// default behavior
35+
function createElement(Component, props) {
36+
// make sure you pass all the props in!
37+
return <Component {...props}/>
38+
}
39+
40+
// maybe you're using something like Relay
41+
function createElement(Component, props) {
42+
// make sure you pass all the props in!
43+
return <RelayContainer Component={Component} routerProps={props}/>;
44+
}
45+
```
46+
47+
#### `stringifyQuery(queryObject)`
48+
49+
A function used to convert an object from `Link`s or calls to
50+
`transitionTo` to a URL query string.
51+
52+
#### `parseQueryString(queryString)`
53+
54+
A function used to convert a query string into an object that gets
55+
passed to route component props.
56+
57+
#### `onError(error)`
58+
59+
While the router is matching, errors may bubble up, here
60+
is your opportunity to catch and deal with them. Typically these will
61+
come from async features like `route.getComponents` and
62+
`route.getChildRoutes`.
63+
64+
### `onUpdate()`
65+
66+
Called whenever the router updates its state in response to URL changes.
67+
68+
Examples
69+
--------
70+
71+
Please see the `examples/` directory of the repository for extensive
72+
exampls of using `Router`.
73+

modules/Router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const { func, object } = React.PropTypes;
1313
* it needs each time the URL changes.
1414
*/
1515
const Router = React.createClass({
16-
16+
1717
propTypes: {
1818
history: object,
1919
children: routes,

0 commit comments

Comments
 (0)