@samitouri / QOS-React / commits / 0f09f14ae6

Check if already rendering before flushing

Forgot to stage this before committing 54e88ed12 I don't think is currently observable but should include the guard to protect against regressions (though this whole block will be deleted along with legacy mode, anyway).

Andrew Clark committed Jul 10, 2021 at 18:02 UTC 0f09f14ae60cfca996c15fc50eeb59447c19a7be
2 files changed +4 -2
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+2 -1
@@ -1086,7 +1086,8 @@ export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
1086 // next event, not at the end of the previous one.
1087 if (
1088 rootWithPendingPassiveEffects !== null &&
1089 - rootWithPendingPassiveEffects.tag === LegacyRoot
1089 + rootWithPendingPassiveEffects.tag === LegacyRoot &&
1090 + (executionContext & (RenderContext | CommitContext)) === NoContext
1091 ) {
1092 flushPassiveEffects();
1093 }
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+2 -1
@@ -1086,7 +1086,8 @@ export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
1086 // next event, not at the end of the previous one.
1087 if (
1088 rootWithPendingPassiveEffects !== null &&
1089 - rootWithPendingPassiveEffects.tag === LegacyRoot
1089 + rootWithPendingPassiveEffects.tag === LegacyRoot &&
1090 + (executionContext & (RenderContext | CommitContext)) === NoContext
1091 ) {
1092 flushPassiveEffects();
1093 }