@@ -112,7 +112,7 @@ import {
112
112
computeAsyncExpiration ,
113
113
computeInteractiveExpiration ,
114
114
} from './ReactFiberExpirationTime' ;
115
- import { AsyncMode , ProfileMode } from './ReactTypeOfMode' ;
115
+ import { AsyncMode , ProfileMode , StrictMode } from './ReactTypeOfMode' ;
116
116
import { enqueueUpdate , resetCurrentlyProcessingQueue } from './ReactUpdateQueue' ;
117
117
import { createCapturedValue } from './ReactCapturedValue' ;
118
118
import {
@@ -777,9 +777,21 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
777
777
unhandledError = error ;
778
778
}
779
779
} 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 ;
780
788
// Don't update interaction counts if we're frozen due to suspense.
781
789
// 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
+ ) {
783
795
// Now that we're done, check the completed batch of interactions.
784
796
// If no more work is outstanding for a given interaction,
785
797
// We need to notify the subscribers that it's finished.
@@ -798,6 +810,8 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
798
810
}
799
811
}
800
812
} ) ;
813
+ } else {
814
+ suspenseDidTimeout = false ;
801
815
}
802
816
}
803
817
}
@@ -1392,6 +1406,7 @@ function renderRoot(
1392
1406
if ( enableSuspense && ! isExpired && nextLatestAbsoluteTimeoutMs !== - 1 ) {
1393
1407
// The tree was suspended.
1394
1408
const suspendedExpirationTime = expirationTime ;
1409
+ suspenseDidTimeout = true ;
1395
1410
markSuspendedPriorityLevel ( root , suspendedExpirationTime ) ;
1396
1411
1397
1412
// Find the earliest uncommitted expiration time in the tree, including
@@ -1928,7 +1943,6 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) {
1928
1943
// Because we know we still need to do more work in this case.
1929
1944
suspenseDidTimeout = true ;
1930
1945
flushRoot ( root , suspendedExpirationTime ) ;
1931
- suspenseDidTimeout = false ;
1932
1946
} else {
1933
1947
flushRoot ( root , suspendedExpirationTime ) ;
1934
1948
}
0 commit comments