Skip to content

Commit fc72ca9

Browse files
committed
Fix alwaysThrottleDisappearingFallbacks
1 parent 5dbe02c commit fc72ca9

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
useModernStrictMode,
3939
disableLegacyContext,
4040
alwaysThrottleRetries,
41+
alwaysThrottleDisappearingFallbacks,
4142
enableInfiniteRenderLoopDetection,
4243
} from 'shared/ReactFeatureFlags';
4344
import ReactSharedInternals from 'shared/ReactSharedInternals';
@@ -1128,7 +1129,9 @@ function finishConcurrentRender(
11281129
} else {
11291130
if (
11301131
includesOnlyRetries(lanes) &&
1131-
(alwaysThrottleRetries || exitStatus === RootSuspended)
1132+
(alwaysThrottleRetries ||
1133+
(alwaysThrottleDisappearingFallbacks && exitStatus === RootCompleted) ||
1134+
exitStatus === RootSuspended)
11321135
) {
11331136
// This render only included retries, no updates. Throttle committing
11341137
// retries so that we don't show too many loading states too quickly.

packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
17571757
// Restart and render the complete content.
17581758
await waitForAll(['A', 'B']);
17591759

1760-
if (gate(flags => flags.alwaysThrottleRetries)) {
1760+
if (
1761+
gate(
1762+
flags =>
1763+
flags.alwaysThrottleDisappearingFallbacks ||
1764+
flags.alwaysThrottleRetries,
1765+
)
1766+
) {
17611767
// Correct behavior:
17621768
//
17631769
// The tree will finish but we won't commit the result yet because the fallback appeared recently.
@@ -1848,11 +1854,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
18481854

18491855
if (
18501856
// This behavior only applies if both flags are enabled.
1851-
gate(
1852-
flags =>
1853-
flags.alwaysThrottleDisappearingFallbacks &&
1854-
flags.alwaysThrottleRetries,
1855-
)
1857+
gate(flags => flags.alwaysThrottleDisappearingFallbacks)
18561858
) {
18571859
// B should not commit yet. Even though it's been a long time since its
18581860
// fallback was shown, it hasn't been long since A appeared. So B's

0 commit comments

Comments
 (0)