@@ -112,7 +112,7 @@ import {
112112 computeAsyncExpiration ,
113113 computeInteractiveExpiration ,
114114} from './ReactFiberExpirationTime' ;
115- import { AsyncMode , ProfileMode } from './ReactTypeOfMode' ;
115+ import { AsyncMode , ProfileMode , StrictMode } from './ReactTypeOfMode' ;
116116import { enqueueUpdate , resetCurrentlyProcessingQueue } from './ReactUpdateQueue' ;
117117import { createCapturedValue } from './ReactCapturedValue' ;
118118import {
@@ -777,9 +777,21 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
777777 unhandledError = error ;
778778 }
779779 } finally {
780+ const updateExpirationTime = root . expirationTime ;
781+ const childExpirationTime = finishedWork . childExpirationTime ;
782+ const earliestRemainingTime =
783+ updateExpirationTime === NoWork ||
784+ ( childExpirationTime !== NoWork &&
785+ childExpirationTime < updateExpirationTime )
786+ ? childExpirationTime
787+ : updateExpirationTime ;
780788 // Don't update interaction counts if we're frozen due to suspense.
781789 // In this case, we can skip the completed-work check entirely.
782- if ( ! suspenseDidTimeout ) {
790+ if (
791+ ! suspenseDidTimeout &&
792+ ( ( finishedWork . mode & StrictMode ) !== NoEffect ||
793+ earliestRemainingTime === 0 )
794+ ) {
783795 // Now that we're done, check the completed batch of interactions.
784796 // If no more work is outstanding for a given interaction,
785797 // We need to notify the subscribers that it's finished.
@@ -798,6 +810,8 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
798810 }
799811 }
800812 } ) ;
813+ } else {
814+ suspenseDidTimeout = false ;
801815 }
802816 }
803817 }
@@ -1392,6 +1406,7 @@ function renderRoot(
13921406 if ( enableSuspense && ! isExpired && nextLatestAbsoluteTimeoutMs !== - 1 ) {
13931407 // The tree was suspended.
13941408 const suspendedExpirationTime = expirationTime ;
1409+ suspenseDidTimeout = true ;
13951410 markSuspendedPriorityLevel ( root , suspendedExpirationTime ) ;
13961411
13971412 // Find the earliest uncommitted expiration time in the tree, including
@@ -1928,7 +1943,6 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) {
19281943 // Because we know we still need to do more work in this case.
19291944 suspenseDidTimeout = true ;
19301945 flushRoot ( root , suspendedExpirationTime ) ;
1931- suspenseDidTimeout = false ;
19321946 } else {
19331947 flushRoot ( root , suspendedExpirationTime ) ;
19341948 }
0 commit comments