Skip to content

Commit a743d9a

Browse files
committed
migrated Redirect doc
1 parent e43f053 commit a743d9a

File tree

3 files changed

+17
-29
lines changed

3 files changed

+17
-29
lines changed

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
- [Confirming Navigation](ConfirmingNavigation.md)
88
- [Glossary](Glossary.md)
99
- [Route](Route.md)
10+
- [Plain Route](Plain Route.md)
11+
- [Redirect](Redirect.md)
1012

1113
- [Server Rendering](ServerRendering.md)
Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,41 @@
1+
## Redirect
2+
13
A `Redirect` sets up a redirect to another route in your application to
24
maintain old URLs.
35

4-
Props
5-
-----
6+
### Props
67

7-
### `from`
8+
#### `from`
89

910
The path you want to redirect from, including dynamic segments.
1011

11-
### `to`
12-
13-
The route path you want to redirect to.
14-
15-
### `params`
12+
#### `to`
1613

17-
By default, the parameters will just pass through to the new route, but
18-
you can specify them if you need to (usually you shouldn't).
14+
The path you want to redirect to.
1915

20-
### `query`
16+
#### `query`
2117

22-
By default, the query parameters will just pass through to the new
23-
route, but you can specify them if you need to (usually you shouldn't).
18+
By default, the query parameters will just pass through but you can
19+
specify them if you need to.
2420

25-
Example
26-
-------
21+
### Example
2722

2823
```js
2924
// lets say we want to change from `/profile/123` to `/about/123`
3025
// and redirect `/get-in-touch` to `/contact`
3126
<Route component={App}>
32-
<Route path="contact" component={Contact}/>
3327
<Route path="about/:userId" component={UserProfile}/>
34-
<Route path="course/:courseId">
35-
<Route path="dashboard" component={Dashboard}/>
36-
<Route path="assignments" component={Assignments}/>
37-
</Route>
38-
39-
{/* `/get-in-touch` -> `/contact` */}
40-
<Redirect from="/get-in-touch" to="/contact" />
4128

4229
{/* `/profile/123` -> `/about/123` */}
4330
<Redirect from="/profile/:userId" to="/about/:userId" />
44-
45-
{/* `/profile/me` -> `/about/123` */}
46-
<Redirect from="/profile/me" to="/about/:userId" params={{userId: SESSION.USER_ID}}/>
4731
</Route>
4832
```
4933

5034
Note that the `<Redirect/>` can be placed anywhere in the route
5135
hierarchy, if you'd prefer the redirects to be next to their respective
5236
routes, the `from` path will match the same as a regular route `path`.
53-
Currently, the `to` property of `<Redirect/>` needs to be an absolute path.
37+
Currently, the `to` property of `<Redirect/>` needs to be an absolute
38+
path. Pull requests welcome to make them handle relative paths too!
5439

5540
```js
5641
<Route path="course/:courseId">
@@ -59,3 +44,4 @@ Currently, the `to` property of `<Redirect/>` needs to be an absolute path.
5944
<Redirect from="home" to="/course/:courseId/dashboard" />
6045
</Route>
6146
```
47+

modules/Redirect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var Redirect = React.createClass({
4444
}
4545

4646
},
47-
47+
4848
propTypes: {
4949
path: string,
5050
from: string, // Alias for path
@@ -61,7 +61,7 @@ var Redirect = React.createClass({
6161
'<Redirect> elements are for router configuration only and should not be rendered'
6262
);
6363
}
64-
64+
6565
});
6666

6767
export default Redirect;

0 commit comments

Comments
 (0)