Moved passive effects flag to be beside execution context (#18322)
Brian Vaughn committed
Mar 16, 2020 at 10:27 UTC
297f7588c46dc50f7439cf197d28d7686bd8d45d
1 file changed
+9
-8
packages/react-reconciler/src/ReactFiberWorkLoop.js
+9
-8
@@ -2276,10 +2276,6 @@ function flushPassiveEffectsImpl() {
2276
return false;
2277
}
2278
2279
- if (__DEV__) {
2280
- isFlushingPassiveEffects = true;
2281
- }
2282
-
2279
const root = rootWithPendingPassiveEffects;
2280
const expirationTime = pendingPassiveEffectsExpirationTime;
2281
rootWithPendingPassiveEffects = null;
@@ -2289,6 +2285,11 @@ function flushPassiveEffectsImpl() {
2285
(executionContext & (RenderContext | CommitContext)) === NoContext,
2286
'Cannot flush passive effects while already rendering.',
2287
);
2288
+
2289
+ if (__DEV__) {
2290
+ isFlushingPassiveEffects = true;
2291
+ }
2292
+
2293
const prevExecutionContext = executionContext;
2294
executionContext |= CommitContext;
2295
const prevInteractions = pushInteractions(root);
@@ -2445,6 +2446,10 @@ function flushPassiveEffectsImpl() {
2446
finishPendingInteractions(root, expirationTime);
2447
}
2448
2449
+ if (__DEV__) {
2450
+ isFlushingPassiveEffects = false;
2451
+ }
2452
+
2453
executionContext = prevExecutionContext;
2454
2455
flushSyncCallbackQueue();
@@ -2454,10 +2459,6 @@ function flushPassiveEffectsImpl() {
2459
nestedPassiveUpdateCount =
2460
rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
2461
2457
- if (__DEV__) {
2458
- isFlushingPassiveEffects = false;
2459
- }
2460
-
2462
return true;
2463
}
2464