Skip to content

Commit f07c696

Browse files
committed
migrated Navigation doc
1 parent 544fe91 commit f07c696

File tree

2 files changed

+86
-63
lines changed

2 files changed

+86
-63
lines changed

doc/03 Mixins/Navigation.md

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

docs/Navigation.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Navigation Mixin
2+
3+
Mixes in the navigation methods of the router for convenient routing
4+
from within components.
5+
6+
## Methods
7+
8+
### `transitionTo(pathname, query, state)`
9+
10+
Transitions to a new URL.
11+
12+
#### arguments
13+
14+
- `pathname` - the full url with or without the query.
15+
- `query` - an object that will be stringified by the router.
16+
- `state` - the location state.
17+
18+
#### Examples
19+
20+
```js
21+
router.transitionTo('/users/123');
22+
router.transitionTo('/users/123', {showGrades: true}); // -> /users/123?showGrades=true
23+
router.transitionTo('/pictures/123', null, { fromDashboard: true });
24+
```
25+
26+
### `replaceWith(pathname, query, state)`
27+
28+
Replaces the current URL with a new one, without affecting the length of
29+
the history (like a redirect).
30+
31+
#### arguments
32+
33+
- `pathname` - the full url with or without the query.
34+
- `query` - an object that will be stringified by the router.
35+
- `state` - the location state.
36+
37+
#### Examples
38+
39+
```js
40+
router.replaceWith('/users/123');
41+
router.replaceWith('/users/123', {showGrades: true}); // -> /users/123?showGrades=true
42+
router.replaceWith('/pictures/123', null, { fromDashboard: true });
43+
```
44+
45+
### `go(n)`
46+
47+
Go forward or backward in the history by `n` or `-n`.
48+
49+
### `goBack()`
50+
51+
Go back one entry in the history.
52+
53+
### `goForward()`
54+
55+
Go forward one entry in the history.
56+
57+
### `createPath(pathname, query)`
58+
59+
Stringifies the query into the pathname, using the router's config.
60+
61+
### `createHref(pathname, query)`
62+
63+
Creates a URL, using the router's config. For example, it will add `#/` in
64+
front of the `pathname` for `HashHistory`.
65+
66+
## Example
67+
68+
```js
69+
import { Navigation } from 'react-router';
70+
71+
React.createClass({
72+
73+
mixins: [ Navigation ],
74+
75+
render() {
76+
return (
77+
<div>
78+
<div onClick={() => this.transitionTo('foo')}>Go to foo</div>
79+
<div onClick={() => this.replaceWith('bar')}>Go to bar without creating a new history entry</div>
80+
<div onClick={() => this.goBack()}>Go back</div>
81+
</div>
82+
)
83+
}
84+
})
85+
```
86+

0 commit comments

Comments
 (0)