File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import invariant from 'invariant' ;
3
3
import { createRouteFromReactElement } from './RouteUtils' ;
4
+ import { formatPattern } from './URLUtils' ;
4
5
import { falsy } from './PropTypes' ;
5
6
6
- var { string } = React . PropTypes ;
7
+ var { string, object } = React . PropTypes ;
7
8
8
9
export var Redirect = React . createClass ( {
9
10
@@ -15,8 +16,15 @@ export var Redirect = React.createClass({
15
16
if ( route . from )
16
17
route . path = route . from ;
17
18
18
- route . onEnter = function ( nextState , router ) {
19
- router . replaceWith ( route . to , nextState . query ) ;
19
+ route . onEnter = function ( nextState , transition ) {
20
+ var { location, params } = nextState ;
21
+ var pathname = route . to ? formatPattern ( route . to , params ) : location . pathname ;
22
+
23
+ transition . to (
24
+ pathname ,
25
+ route . query || location . query ,
26
+ route . state || location . state
27
+ ) ;
20
28
} ;
21
29
22
30
return route ;
@@ -25,8 +33,11 @@ export var Redirect = React.createClass({
25
33
} ,
26
34
27
35
propTypes : {
28
- from : string ,
36
+ path : string ,
37
+ from : string , // Alias for path
29
38
to : string . isRequired ,
39
+ query : object ,
40
+ state : object ,
30
41
onEnter : falsy ,
31
42
children : falsy
32
43
} ,
You can’t perform that action at this time.
0 commit comments