@@ -87,7 +87,8 @@ export var Router = React.createClass({
87
87
88
88
propTypes : {
89
89
history : history . isRequired ,
90
- children : routes . isRequired ,
90
+ children : routes ,
91
+ routes, // Alias for children
91
92
createElement : func . isRequired ,
92
93
onError : func . isRequired ,
93
94
onUpdate : func ,
@@ -122,7 +123,7 @@ export var Router = React.createClass({
122
123
_updateState ( location ) {
123
124
invariant (
124
125
Location . isLocation ( location ) ,
125
- 'Router needs a valid Location'
126
+ 'A < Router> needs a valid Location'
126
127
) ;
127
128
128
129
this . nextLocation = location ;
@@ -261,9 +262,14 @@ export var Router = React.createClass({
261
262
} ,
262
263
263
264
componentWillMount ( ) {
264
- var { children , history } = this . props ;
265
+ var { history , routes , children } = this . props ;
265
266
266
- this . routes = createRoutes ( children ) ;
267
+ invariant (
268
+ routes || children ,
269
+ 'A <Router> needs some routes'
270
+ ) ;
271
+
272
+ this . routes = createRoutes ( routes || children ) ;
267
273
this . transitionHooks = [ ] ;
268
274
this . nextLocation = null ;
269
275
@@ -292,8 +298,11 @@ export var Router = React.createClass({
292
298
'<Router history> may not be changed'
293
299
) ;
294
300
295
- if ( this . props . children !== nextProps . children ) {
296
- this . routes = createRoutes ( nextProps . children ) ;
301
+ var currentRoutes = this . props . routes || this . props . children ;
302
+ var nextRoutes = nextProps . routes || nextProps . children ;
303
+
304
+ if ( currentRoutes !== nextRoutes ) {
305
+ this . routes = createRoutes ( nextRoutes ) ;
297
306
298
307
// Call this here because _updateState
299
308
// uses this.routes to determine state.
0 commit comments