@@ -55,36 +55,43 @@ const Router = React.createClass({
55
55
}
56
56
} ,
57
57
58
- componentWillMount ( ) {
59
- const { transitionManager, router } = this . createRouterObjects ( )
60
-
61
- this . _unlisten = transitionManager . listen ( ( error , state ) => {
62
- if ( error ) {
63
- this . handleError ( error )
64
- } else {
65
- this . setState ( state , this . props . onUpdate )
66
- }
67
- } )
58
+ createRouterObject ( state ) {
59
+ const { matchContext } = this . props
60
+ if ( matchContext ) {
61
+ return matchContext . router
62
+ }
68
63
69
- this . router = router
64
+ const { history } = this . props
65
+ return createRouterObject ( history , this . transitionManager , state )
70
66
} ,
71
67
72
- createRouterObjects ( ) {
68
+ createTransitionManager ( ) {
73
69
const { matchContext } = this . props
74
70
if ( matchContext ) {
75
- return matchContext
71
+ return matchContext . transitionManager
76
72
}
77
73
78
- let { history } = this . props
74
+ const { history } = this . props
79
75
const { routes, children } = this . props
80
76
81
- const transitionManager = createTransitionManager (
77
+ return createTransitionManager (
82
78
history ,
83
79
createRoutes ( routes || children )
84
80
)
85
- const router = createRouterObject ( history , transitionManager )
81
+ } ,
86
82
87
- return { transitionManager, router }
83
+ componentWillMount ( ) {
84
+ this . transitionManager = this . createTransitionManager ( )
85
+ this . router = this . createRouterObject ( this . state )
86
+
87
+ this . _unlisten = this . transitionManager . listen ( ( error , state ) => {
88
+ if ( error ) {
89
+ this . handleError ( error )
90
+ } else {
91
+ this . router = this . createRouterObject ( state )
92
+ this . setState ( state , this . props . onUpdate )
93
+ }
94
+ } )
88
95
} ,
89
96
90
97
/* istanbul ignore next: sanity check */
0 commit comments