Skip to content

Commit 838aa8b

Browse files
committed
Flush legacy passive effects at beginning of event
Fixes test added in previous commit.
1 parent 1a63add commit 838aa8b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,15 @@ export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
10821082
fn: A => R,
10831083
a: A,
10841084
): R {
1085+
// In legacy mode, we flush pending passive effects at the beginning of the
1086+
// next event, not at the end of the previous one.
1087+
if (
1088+
rootWithPendingPassiveEffects !== null &&
1089+
rootWithPendingPassiveEffects.tag === LegacyRoot
1090+
) {
1091+
flushPassiveEffects();
1092+
}
1093+
10851094
const prevExecutionContext = executionContext;
10861095
executionContext |= BatchedContext;
10871096

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,15 @@ export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
10821082
fn: A => R,
10831083
a: A,
10841084
): R {
1085+
// In legacy mode, we flush pending passive effects at the beginning of the
1086+
// next event, not at the end of the previous one.
1087+
if (
1088+
rootWithPendingPassiveEffects !== null &&
1089+
rootWithPendingPassiveEffects.tag === LegacyRoot
1090+
) {
1091+
flushPassiveEffects();
1092+
}
1093+
10851094
const prevExecutionContext = executionContext;
10861095
executionContext |= BatchedContext;
10871096

0 commit comments

Comments
 (0)