Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
useModernStrictMode,
disableLegacyContext,
alwaysThrottleRetries,
alwaysThrottleDisappearingFallbacks,
enableInfiniteRenderLoopDetection,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
Expand Down Expand Up @@ -1128,7 +1129,9 @@ function finishConcurrentRender(
} else {
if (
includesOnlyRetries(lanes) &&
(alwaysThrottleRetries || exitStatus === RootSuspended)
(alwaysThrottleRetries ||
(alwaysThrottleDisappearingFallbacks && exitStatus === RootCompleted) ||
exitStatus === RootSuspended)
) {
// This render only included retries, no updates. Throttle committing
// retries so that we don't show too many loading states too quickly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
// Restart and render the complete content.
await waitForAll(['A', 'B']);

if (gate(flags => flags.alwaysThrottleRetries)) {
if (
gate(
flags =>
flags.alwaysThrottleDisappearingFallbacks ||
flags.alwaysThrottleRetries,
)
) {
// Correct behavior:
//
// The tree will finish but we won't commit the result yet because the fallback appeared recently.
Expand Down Expand Up @@ -1846,7 +1852,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
await resolveText('B');
await waitForPaint(['B']);

if (gate(flags => flags.alwaysThrottleRetries)) {
if (
// This behavior only applies if both flags are enabled.
gate(flags => flags.alwaysThrottleDisappearingFallbacks)
) {
// B should not commit yet. Even though it's been a long time since its
// fallback was shown, it hasn't been long since A appeared. So B's
// appearance is throttled to reduce jank.
Expand Down