1
1
import invariant from 'invariant'
2
2
import React , { Component } from 'react'
3
+ import { isReactChildren } from './RouteUtils'
3
4
import getRouteParams from './getRouteParams'
4
5
5
6
const { array, func, object } = React . PropTypes
@@ -46,7 +47,7 @@ class RoutingContext extends Component {
46
47
if ( components ) {
47
48
element = components . reduceRight ( ( element , components , index ) => {
48
49
if ( components == null )
49
- return element // Don't create new children use the grandchildren.
50
+ return element // Don't create new children; use the grandchildren.
50
51
51
52
const route = routes [ index ]
52
53
const routeParams = getRouteParams ( route , params )
@@ -59,13 +60,18 @@ class RoutingContext extends Component {
59
60
routes
60
61
}
61
62
62
- if ( element )
63
+ if ( isReactChildren ( element ) ) {
63
64
props . children = element
65
+ } else if ( element ) {
66
+ for ( let prop in element )
67
+ if ( element . hasOwnProperty ( prop ) )
68
+ props [ prop ] = element [ prop ]
69
+ }
64
70
65
71
if ( typeof components === 'object' ) {
66
72
const elements = { }
67
73
68
- for ( const key in components )
74
+ for ( let key in components )
69
75
if ( components . hasOwnProperty ( key ) )
70
76
elements [ key ] = this . createElement ( components [ key ] , props )
71
77
0 commit comments