Skip to content

Commit 7f5e85c

Browse files
committed
Update docs
1 parent 498d31e commit 7f5e85c

File tree

7 files changed

+60
-122
lines changed

7 files changed

+60
-122
lines changed

docs/api/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ React Router API
1212
- [`RouteHandler`](/docs/api/components/RouteHandler.md)
1313
- [`Routes`](/docs/api/components/Routes.md)
1414

15-
- Misc
16-
- [`transition`](/docs/api/misc/transition.md)
17-
1815
- Mixins
1916
- [`ActiveState`](/docs/api/mixins/ActiveState.md)
2017
- [`AsyncState`](/docs/api/mixins/AsyncState.md)
21-
- [`PathState`](/docs/api/mixins/PathState.md)
22-
- [`RouteLookup`](/docs/api/mixins/RouteLookup.md)
23-
- [`Transitions`](/docs/api/mixins/Transitions.md)
18+
- [`CurrentPath`](/docs/api/mixins/CurrentPath.md)
19+
- [`Navigation`](/docs/api/mixins/Navigation.md)
20+
21+
- Misc
22+
- [`transition`](/docs/api/misc/transition.md)
2423

2524
Public Modules
2625
--------------

docs/api/misc/Location.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ following methods must be implemented:
77
Methods
88
-------
99

10-
### `setup(onChange)`
10+
### `setup()`
1111

12-
Called when the router is first setup. Whenever an external actor should
13-
cause the router to react, call `onChange` (for example, on
14-
`window.hashchange`).
12+
Called when the router is first setup.
1513

1614
### `teardown`
1715

@@ -30,10 +28,6 @@ another.
3028

3129
Called when the router attempts to go back one entry in the history.
3230

33-
### `getCurrentPath`
34-
35-
Should return the current path as a string.
36-
3731
### `toString`
3832

3933
Should return a useful string for logging and debugging.
@@ -47,7 +41,7 @@ implementations in this repository.
4741
```js
4842
var MyLocation = {
4943

50-
setup: function (onChange) {},
44+
setup: function () {},
5145

5246
teardown: function () {},
5347

@@ -57,10 +51,7 @@ var MyLocation = {
5751

5852
pop: function () {},
5953

60-
getCurrentPath: function () {},
61-
6254
toString: function () {}
6355

6456
};
6557
```
66-

docs/api/mixins/ActiveState.md

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@ query that are currently active (like links).
77
Instance Methods
88
----------------
99

10-
### `isActive(routeName, params, query)`
10+
### `getActiveRoutes()`
1111

12-
Returns `true` if a route, params, and query are active, `false`
13-
otherwise.
12+
Returns an array of the `<Route>`s that are currently active.
13+
14+
### `getActiveParams()`
15+
16+
Returns a hash of the currently active URL params.
17+
18+
### `getActiveQuery()`
1419

15-
Lifecycle Methods
16-
-----------------
20+
Returns a hash of the currently active query params.
1721

18-
### `updateActiveState`
22+
### `isActive(routeName, params, query)`
1923

20-
Called when the active state changes.
24+
Returns `true` if a route, params, and query are active, `false`
25+
otherwise.
2126

2227
Example
2328
-------
@@ -26,25 +31,16 @@ Let's say you are using bootstrap and want to get `active` on those `li`
2631
tags for the Tabs:
2732

2833
```js
29-
var Link = require('react-router/Link');
30-
var ActiveState = require('react-router/ActiveState');
34+
var Link = require('react-router').Link;
35+
var ActiveState = require('react-router').ActiveState;
3136

3237
var Tab = React.createClass({
3338

3439
mixins: [ ActiveState ],
3540

36-
getInitialState: function () {
37-
return { isActive: false };
38-
},
39-
40-
updateActiveState: function () {
41-
this.setState({
42-
isActive: this.isActive(this.props.to, this.props.params, this.props.query)
43-
})
44-
},
45-
4641
render: function() {
47-
var className = this.state.isActive ? 'active' : '';
42+
var isActive = this.isActive(this.props.to, this.props.params, this.props.query);
43+
var className = isActive ? 'active' : '';
4844
var link = Link(this.props);
4945
return <li className={className}>{link}</li>;
5046
}
@@ -55,4 +51,3 @@ var Tab = React.createClass({
5551
// with an automatic `active` class on both.
5652
<Tab to="foo">Foo</Tab>
5753
```
58-

docs/api/mixins/CurrentPath.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
API: `CurrentPath` (mixin)
2+
==========================
3+
4+
A mixin for components that need to know the current URL path.
5+
6+
Instance Methods
7+
----------------
8+
9+
### `getCurrentPath()`
10+
11+
Returns the current URL path.
12+
13+
Example
14+
-------
15+
16+
```js
17+
var CurrentPath = require('react-router').CurrentPath;
18+
19+
var ShowThePath = React.createClass({
20+
mixins: [ CurrentPath ],
21+
render: function () {
22+
return (
23+
<div>The current path is: {this.getCurrentPath()}</div>
24+
);
25+
}
26+
});
27+
```

docs/api/mixins/Transitions.md renamed to docs/api/mixins/Navigation.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
API: `Transitions` (mixin)
1+
API: `Navigation` (mixin)
22
==========================
33

4-
A mixin for components that need to initiate transitions to other routes.
4+
A mixin for components that need to create URLs and/or initiate transitions to other routes.
55

66
Instance Methods
77
----------------
@@ -43,6 +43,10 @@ entry from the browser history.
4343
this.goBack();
4444
```
4545

46+
### `makePath(routeName, params, query)`
47+
48+
Creates a URL path to a route.
49+
4650
### `makeHref(routeName, params, query)`
4751

4852
Creates an `href` to a route. Use this along with `ActiveState` when you
@@ -60,8 +64,10 @@ Example
6064
-------
6165

6266
```js
67+
var Navigation = require('react-router').Navigation;
68+
6369
React.createClass({
64-
mixins: [Transitions],
70+
mixins: [Navigation],
6571

6672
whenever: function() {
6773
this.transitionTo('something');
@@ -70,4 +76,3 @@ React.createClass({
7076
}
7177
});
7278
```
73-

docs/api/mixins/PathState.md

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

docs/api/mixins/RouteLookup.md

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

0 commit comments

Comments
 (0)