Skip to content

Commit 61643ea

Browse files
committed
Add doc comment
1 parent 415261d commit 61643ea

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

modules/components/Redirect.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
var React = require('react');
22
var Route = require('./Route');
33

4-
function Redirect(props) {
5-
return Route({
6-
name: props.name,
7-
path: props.from,
8-
handler: createRedirectClass(props.to)
9-
});
10-
}
11-
12-
function createRedirectClass(to) {
4+
function createRedirectHandler(to) {
135
return React.createClass({
146
statics: {
157
willTransitionTo: function (transition, params, query) {
@@ -23,4 +15,16 @@ function createRedirectClass(to) {
2315
});
2416
}
2517

18+
/**
19+
* A <Redirect> component is a special kind of <Route> that always
20+
* redirects when it matches.
21+
*/
22+
function Redirect(props) {
23+
return Route({
24+
name: props.name,
25+
path: props.from || props.path,
26+
handler: createRedirectHandler(props.to)
27+
});
28+
}
29+
2630
module.exports = Redirect;

0 commit comments

Comments
 (0)