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 11import React from 'react' ;
22import invariant from 'invariant' ;
33import { createRouteFromReactElement } from './RouteUtils' ;
4+ import { formatPattern } from './URLUtils' ;
45import { falsy } from './PropTypes' ;
56
6- var { string } = React . PropTypes ;
7+ var { string, object } = React . PropTypes ;
78
89export var Redirect = React . createClass ( {
910
@@ -15,8 +16,15 @@ export var Redirect = React.createClass({
1516 if ( route . from )
1617 route . path = route . from ;
1718
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+ ) ;
2028 } ;
2129
2230 return route ;
@@ -25,8 +33,11 @@ export var Redirect = React.createClass({
2533 } ,
2634
2735 propTypes : {
28- from : string ,
36+ path : string ,
37+ from : string , // Alias for path
2938 to : string . isRequired ,
39+ query : object ,
40+ state : object ,
3041 onEnter : falsy ,
3142 children : falsy
3243 } ,
You can’t perform that action at this time.
0 commit comments