Skip to content

Commit

Permalink
Ensure passive effects are flushed after a suspended commit resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Dec 19, 2024
1 parent a8efb5b commit d94334a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -3278,6 +3278,9 @@ function commitRootImpl(
// We don't schedule a separate task for flushing passive effects.
// Instead, we just rely on ensureRootIsScheduled below to schedule
// a callback for us to flush the passive effects.
// We do need to clear this callback.
// Otherwise, we'll still think the commit is suspended.
root.cancelPendingCommit = null;
} else {
// So we can clear these now to allow a new callback to be scheduled.
root.callbackNode = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,6 @@ describe('ReactSuspenseyCommitPhase', () => {
);
});

// FIXME: Should pass with `enableYieldingBeforePassive`
// @gate !enableYieldingBeforePassive
it('runs passive effects after suspended commit resolves', async () => {
function Effect() {
React.useEffect(() => {
Expand Down
3 changes: 1 addition & 2 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ export const enableLegacyFBSupport = false;
// -----------------------------------------------------------------------------

// Yield to the browser event loop and not just the scheduler event loop before passive effects.
// Fix gated tests that fail with this flag enabled before turning it back on.
export const enableYieldingBeforePassive = false;
export const enableYieldingBeforePassive = __EXPERIMENTAL__;

export const enableLegacyCache = __EXPERIMENTAL__;

Expand Down

0 comments on commit d94334a

Please sign in to comment.