File tree 1 file changed +10
-10
lines changed
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ var Routes = React.createClass({
58
58
} ,
59
59
60
60
propTypes : {
61
+ initialPath : React . PropTypes . string ,
61
62
location : React . PropTypes . oneOf ( [ 'hash' , 'history' ] ) . isRequired ,
62
63
} ,
63
64
@@ -68,7 +69,10 @@ var Routes = React.createClass({
68
69
} ,
69
70
70
71
getInitialState : function ( ) {
71
- return { } ;
72
+ return {
73
+ path : this . props . initialPath ,
74
+ matches : [ ]
75
+ } ;
72
76
} ,
73
77
74
78
componentWillMount : function ( ) {
@@ -83,7 +87,7 @@ var Routes = React.createClass({
83
87
} ,
84
88
85
89
componentDidMount : function ( ) {
86
- this . dispatch ( URLStore . getCurrentPath ( ) ) ;
90
+ this . dispatch ( this . state . path || URLStore . getCurrentPath ( ) ) ;
87
91
} ,
88
92
89
93
componentWillUnmount : function ( ) {
@@ -174,16 +178,12 @@ var Routes = React.createClass({
174
178
} ,
175
179
176
180
render : function ( ) {
177
- if ( ! this . state . path )
178
- return null ;
179
-
180
181
var matches = this . state . matches ;
181
- if ( matches . length ) {
182
- // matches[0] corresponds to the top-most match
183
- return matches [ 0 ] . route . props . handler ( computeHandlerProps ( matches , this . state . activeQuery ) ) ;
184
- } else {
182
+
183
+ if ( matches . length === 0 )
185
184
return null ;
186
- }
185
+
186
+ return getRootMatch ( matches ) . route . props . handler ( computeHandlerProps ( matches , this . state . activeQuery ) ) ;
187
187
}
188
188
189
189
} ) ;
You can’t perform that action at this time.
0 commit comments