@@ -212,7 +212,7 @@ var Route = React.createClass({
212
212
} ,
213
213
214
214
render : function ( ) {
215
- return this . props . handler ( this . state . handlerProps ) ;
215
+ return this . props . handler ( computeHandlerProps ( this . state . matches || [ ] , this . state . query ) ) ;
216
216
}
217
217
218
218
} ) ;
@@ -341,7 +341,7 @@ function syncWithTransition(route, transition) {
341
341
toMatches = nextMatches ;
342
342
}
343
343
344
- return checkTransitionFromHooks ( fromMatches , transition ) . then ( function ( ) {
344
+ return checkTransitionFromHooks ( fromMatches , route . refs , transition ) . then ( function ( ) {
345
345
if ( transition . isCancelled )
346
346
return ; // No need to continue.
347
347
@@ -355,7 +355,6 @@ function syncWithTransition(route, transition) {
355
355
var state = {
356
356
path : transition . path ,
357
357
matches : nextMatches ,
358
- handlerProps : computeHandlerProps ( nextMatches , query ) ,
359
358
activeParams : params ,
360
359
activeQuery : query ,
361
360
activeRoutes : nextMatches . map ( function ( match ) {
@@ -376,15 +375,15 @@ function syncWithTransition(route, transition) {
376
375
* the route's handler, so that the deepest nested handlers are called first.
377
376
* Returns a promise that resolves after the last handler.
378
377
*/
379
- function checkTransitionFromHooks ( matches , transition ) {
378
+ function checkTransitionFromHooks ( matches , refs , transition ) {
380
379
var promise = Promise . resolve ( ) ;
381
380
382
381
reversedArray ( matches ) . forEach ( function ( match ) {
383
382
promise = promise . then ( function ( ) {
384
383
var handler = match . route . props . handler ;
385
384
386
385
if ( ! transition . isCancelled && handler . willTransitionFrom )
387
- return handler . willTransitionFrom ( transition , match . handlerInstance ) ;
386
+ return handler . willTransitionFrom ( transition , refs [ match . refName ] ) ;
388
387
} ) ;
389
388
} ) ;
390
389
@@ -417,31 +416,33 @@ function checkTransitionToHooks(matches, transition) {
417
416
*/
418
417
function computeHandlerProps ( matches , query ) {
419
418
var props = {
419
+ ref : null ,
420
420
key : null ,
421
421
params : null ,
422
422
query : null ,
423
423
activeRoute : null
424
424
} ;
425
425
426
- var previousMatch ;
427
- reversedArray ( matches ) . forEach ( function ( match ) {
426
+ var childDescriptor ;
427
+ reversedArray ( matches ) . forEach ( function ( match , index ) {
428
428
var route = match . route ;
429
429
430
430
props = Route . getUnreservedProps ( route . props ) ;
431
431
432
+ props . ref = 'route-' + index ;
432
433
props . key = Path . injectParams ( route . props . path , match . params ) ;
433
434
props . params = match . params ;
434
435
props . query = query ;
435
436
436
- if ( previousMatch ) {
437
- props . activeRoute = previousMatch . handlerInstance ;
437
+ if ( childDescriptor ) {
438
+ props . activeRoute = childDescriptor ;
438
439
} else {
439
440
props . activeRoute = null ;
440
441
}
441
442
442
- match . handlerInstance = route . props . handler ( props ) ;
443
+ childDescriptor = route . props . handler ( props ) ;
443
444
444
- previousMatch = match ;
445
+ match . refName = props . ref ;
445
446
} ) ;
446
447
447
448
return props ;
0 commit comments