Skip to content

Commit e43f053

Browse files
committed
updated plain routes doc
1 parent fc6de6f commit e43f053

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

doc/01 Route Configuration/Plain Route.md renamed to docs/Plain Route.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
1-
A route configuration object. `Router` turns JSX `<Route/>`s into
2-
these objects, but you can use them directly if you prefer. All of the
3-
props are the same as `<Route/>` props, except those listed here.
1+
## Plain Route
42

5-
Props
6-
-----
3+
A plain JavaScript object route definition. `Router` turns JSX
4+
`<Route/>`s into these objects, but you can use them directly if you
5+
prefer. All of the props are the same as `<Route/>` props, except
6+
those listed here.
77

8-
### `childRoutes`
8+
### Props
9+
10+
#### `childRoutes`
911

1012
An array of child routes, same as `children` in JSX route configs.
1113

12-
### `getChildRoutes(state, callback)`
14+
#### `getChildRoutes(location, callback)`
1315

14-
Same as `childRoutes` but asynchronous and receives the location state.
16+
Same as `childRoutes` but asynchronous and receives the `location`.
1517
Useful for code-splitting and dynamic route matching (given some state
1618
or session data to return a different set of child routes).
1719

18-
#### `callback` signature
20+
##### `callback` signature
1921

2022
`cb(err, routesArray)`
2123

22-
#### Example
24+
### Examples
2325

2426
```js
25-
var myRoute = {
27+
let myRoute = {
2628
path: 'course/:courseId',
2729
childRoutes: [
2830
announcementsRoute,
@@ -32,9 +34,9 @@ var myRoute = {
3234
};
3335

3436
// async child routes
35-
var myRoute = {
37+
let myRoute = {
3638
path: 'course/:courseId',
37-
getChildRoutes (state, cb) {
39+
getChildRoutes (location, cb) {
3840
// do asynchronous stuff to find the child routes
3941
cb(null, [announcementsRoute, gradesRoute, assignmentsRoute]);
4042
}
@@ -44,10 +46,10 @@ var myRoute = {
4446
// can link with some state
4547
<Link to="/picture/123" state={{fromDashboard: true}}/>
4648

47-
var myRoute = {
49+
let myRoute = {
4850
path: 'picture/:id',
49-
getChildRoutes (state, cb) {
50-
// state gets passed to `getChildRoutes`
51+
getChildRoutes (location, cb) {
52+
let { state } = location
5153
if (state && state.fromDashboard)
5254
cb(null, [dashboardPictureRoute])
5355
else

0 commit comments

Comments
 (0)