Skip to content

Commit

Permalink
Flush legacy passive effects at beginning of event
Browse files Browse the repository at this point in the history
Fixes test added in previous commit.
  • Loading branch information
acdlite committed Jul 10, 2021
1 parent 1a63add commit 838aa8b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,15 @@ export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
fn: A => R,
a: A,
): R {
// In legacy mode, we flush pending passive effects at the beginning of the
// next event, not at the end of the previous one.
if (
rootWithPendingPassiveEffects !== null &&
rootWithPendingPassiveEffects.tag === LegacyRoot
) {
flushPassiveEffects();
}

const prevExecutionContext = executionContext;
executionContext |= BatchedContext;

Expand Down
9 changes: 9 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,15 @@ export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
fn: A => R,
a: A,
): R {
// In legacy mode, we flush pending passive effects at the beginning of the
// next event, not at the end of the previous one.
if (
rootWithPendingPassiveEffects !== null &&
rootWithPendingPassiveEffects.tag === LegacyRoot
) {
flushPassiveEffects();
}

const prevExecutionContext = executionContext;
executionContext |= BatchedContext;

Expand Down

0 comments on commit 838aa8b

Please sign in to comment.