@@ -360,6 +360,8 @@ function processTimers(
360
360
delay : number ,
361
361
) : void {
362
362
const timersArr = Array . from ( timers . values ( ) ) ;
363
+ const previousInstance = currentInstance ;
364
+ const previousTimers = currentTimers ;
363
365
try {
364
366
batchedEventUpdates ( ( ) => {
365
367
for ( let i = 0 ; i < timersArr . length ; i ++ ) {
@@ -374,8 +376,8 @@ function processTimers(
374
376
}
375
377
} ) ;
376
378
} finally {
377
- currentTimers = null ;
378
- currentInstance = null ;
379
+ currentTimers = previousTimers ;
380
+ currentInstance = previousInstance ;
379
381
currentTimeStamp = 0 ;
380
382
}
381
383
}
@@ -518,14 +520,16 @@ export function mountEventResponder(
518
520
) {
519
521
const onMount = responder . onMount ;
520
522
if ( onMount !== null ) {
523
+ const previousInstance = currentInstance ;
524
+ const previousTimers = currentTimers ;
521
525
currentInstance = responderInstance ;
522
526
try {
523
527
batchedEventUpdates ( ( ) => {
524
528
onMount ( eventResponderContext , props , state ) ;
525
529
} ) ;
526
530
} finally {
527
- currentInstance = null ;
528
- currentTimers = null ;
531
+ currentInstance = previousInstance ;
532
+ currentTimers = previousTimers ;
529
533
}
530
534
}
531
535
}
@@ -537,14 +541,16 @@ export function unmountEventResponder(
537
541
const onUnmount = responder . onUnmount ;
538
542
if ( onUnmount !== null ) {
539
543
let { props , state } = responderInstance ;
544
+ const previousInstance = currentInstance ;
545
+ const previousTimers = currentTimers ;
540
546
currentInstance = responderInstance ;
541
547
try {
542
548
batchedEventUpdates ( ( ) => {
543
549
onUnmount ( eventResponderContext , props , state ) ;
544
550
} ) ;
545
551
} finally {
546
- currentInstance = null ;
547
- currentTimers = null ;
552
+ currentInstance = previousInstance ;
553
+ currentTimers = previousTimers ;
548
554
}
549
555
}
550
556
const rootEventTypesSet = responderInstance . rootEventTypes ;
0 commit comments