Don't clear other flags when adding Deletion
Same as #20398 but for Deletions. There's no new regression test, but in the effects refactor, existing tests will fail without this.
Andrew Clark committed
Dec 7, 2020 at 15:30 UTC
ff17fc176f959bda67a6c1d8e7d294c4852f9546
13 files changed
+88
-343
packages/react-reconciler/src/ReactChildFiber.new.js
+7
-2
@@ -13,7 +13,12 @@ import type {Fiber} from './ReactInternalTypes';
13
import type {Lanes} from './ReactFiberLane.new';
14
15
import getComponentName from 'shared/getComponentName';
16
-import {Deletion, ChildDeletion, Placement} from './ReactFiberFlags';
16
+import {
17
+ Deletion,
18
+ ChildDeletion,
19
+ Placement,
20
+ StaticMask,
21
+} from './ReactFiberFlags';
22
import {
23
getIteratorFn,
24
REACT_ELEMENT_TYPE,
@@ -275,7 +280,7 @@ function ChildReconciler(shouldTrackSideEffects) {
280
returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
281
}
282
childToDelete.nextEffect = null;
278
- childToDelete.flags = Deletion;
283
+ childToDelete.flags = (childToDelete.flags & StaticMask) | Deletion;
284
285
let deletions = returnFiber.deletions;
286
if (deletions === null) {
packages/react-reconciler/src/ReactChildFiber.old.js
+7
-2
@@ -13,7 +13,12 @@ import type {Fiber} from './ReactInternalTypes';
13
import type {Lanes} from './ReactFiberLane.old';
14
15
import getComponentName from 'shared/getComponentName';
16
-import {Deletion, ChildDeletion, Placement} from './ReactFiberFlags';
16
+import {
17
+ Deletion,
18
+ ChildDeletion,
19
+ Placement,
20
+ StaticMask,
21
+} from './ReactFiberFlags';
22
import {
23
getIteratorFn,
24
REACT_ELEMENT_TYPE,
@@ -275,7 +280,7 @@ function ChildReconciler(shouldTrackSideEffects) {
280
returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
281
}
282
childToDelete.nextEffect = null;
278
- childToDelete.flags = Deletion;
283
+ childToDelete.flags = (childToDelete.flags & StaticMask) | Deletion;
284
285
let deletions = returnFiber.deletions;
286
if (deletions === null) {
packages/react-reconciler/src/ReactFiberBeginWork.new.js
+3
-2
@@ -2007,7 +2007,8 @@ function updateSuspensePrimaryChildren(
2007
if (currentFallbackChildFragment !== null) {
2008
// Delete the fallback child fragment
2009
currentFallbackChildFragment.nextEffect = null;
2010
- currentFallbackChildFragment.flags = Deletion;
2010
+ currentFallbackChildFragment.flags =
2011
+ (currentFallbackChildFragment.flags & StaticMask) | Deletion;
2012
workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment;
2013
let deletions = workInProgress.deletions;
2014
if (deletions === null) {
@@ -2998,7 +2999,7 @@ function remountFiber(
2999
returnFiber.firstEffect = returnFiber.lastEffect = current;
3000
}
3001
current.nextEffect = null;
3001
- current.flags = Deletion;
3002
+ current.flags = (current.flags & StaticMask) | Deletion;
3003
3004
let deletions = returnFiber.deletions;
3005
if (deletions === null) {
packages/react-reconciler/src/ReactFiberBeginWork.old.js
+3
-2
@@ -2007,7 +2007,8 @@ function updateSuspensePrimaryChildren(
2007
if (currentFallbackChildFragment !== null) {
2008
// Delete the fallback child fragment
2009
currentFallbackChildFragment.nextEffect = null;
2010
- currentFallbackChildFragment.flags = Deletion;
2010
+ currentFallbackChildFragment.flags =
2011
+ (currentFallbackChildFragment.flags & StaticMask) | Deletion;
2012
workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment;
2013
let deletions = workInProgress.deletions;
2014
if (deletions === null) {
@@ -2998,7 +2999,7 @@ function remountFiber(
2999
returnFiber.firstEffect = returnFiber.lastEffect = current;
3000
}
3001
current.nextEffect = null;
3001
- current.flags = Deletion;
3002
+ current.flags = (current.flags & StaticMask) | Deletion;
3003
3004
let deletions = returnFiber.deletions;
3005
if (deletions === null) {
packages/react-reconciler/src/ReactFiberClassComponent.old.js
+6
-39
@@ -12,14 +12,13 @@ import type {Lanes} from './ReactFiberLane.old';
12
import type {UpdateQueue} from './ReactUpdateQueue.old';
13
14
import * as React from 'react';
15
-import {Update, Snapshot, MountLayoutDev} from './ReactFiberFlags';
15
+import {Update, Snapshot} from './ReactFiberFlags';
16
import {
17
debugRenderPhaseSideEffectsForStrictMode,
18
disableLegacyContext,
19
enableDebugTracing,
20
enableSchedulingProfiler,
21
warnAboutDeprecatedLifecycles,
22
- enableDoubleInvokingEffects,
22
} from 'shared/ReactFeatureFlags';
23
import ReactStrictModeWarnings from './ReactStrictModeWarnings.old';
24
import {isMounted} from './ReactFiberTreeReflection';
@@ -30,7 +29,7 @@ import invariant from 'shared/invariant';
29
import {REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE} from 'shared/ReactSymbols';
30
31
import {resolveDefaultProps} from './ReactFiberLazyComponent.old';
33
-import {DebugTracingMode, NoMode, StrictMode} from './ReactTypeOfMode';
32
+import {DebugTracingMode, StrictMode} from './ReactTypeOfMode';
33
34
import {
35
enqueueUpdate,
@@ -891,15 +890,7 @@ function mountClassInstance(
890
}
891
892
if (typeof instance.componentDidMount === 'function') {
894
- if (
895
- __DEV__ &&
896
- enableDoubleInvokingEffects &&
897
- (workInProgress.mode & StrictMode) !== NoMode
898
- ) {
899
- workInProgress.flags |= MountLayoutDev | Update;
900
- } else {
901
- workInProgress.flags |= Update;
902
- }
893
+ workInProgress.flags |= Update;
894
}
895
}
896
@@ -969,15 +960,7 @@ function resumeMountClassInstance(
960
// If an update was already in progress, we should schedule an Update
961
// effect even though we're bailing out, so that cWU/cDU are called.
962
if (typeof instance.componentDidMount === 'function') {
972
- if (
973
- __DEV__ &&
974
- enableDoubleInvokingEffects &&
975
- (workInProgress.mode & StrictMode) !== NoMode
976
- ) {
977
- workInProgress.flags |= MountLayoutDev | Update;
978
- } else {
979
- workInProgress.flags |= Update;
980
- }
963
+ workInProgress.flags |= Update;
964
}
965
return false;
966
}
@@ -1020,29 +1003,13 @@ function resumeMountClassInstance(
1003
}
1004
}
1005
if (typeof instance.componentDidMount === 'function') {
1023
- if (
1024
- __DEV__ &&
1025
- enableDoubleInvokingEffects &&
1026
- (workInProgress.mode & StrictMode) !== NoMode
1027
- ) {
1028
- workInProgress.flags |= MountLayoutDev | Update;
1029
- } else {
1030
- workInProgress.flags |= Update;
1031
- }
1006
+ workInProgress.flags |= Update;
1007
}
1008
} else {
1009
// If an update was already in progress, we should schedule an Update
1010
// effect even though we're bailing out, so that cWU/cDU are called.
1011
if (typeof instance.componentDidMount === 'function') {
1037
- if (
1038
- __DEV__ &&
1039
- enableDoubleInvokingEffects &&
1040
- (workInProgress.mode & StrictMode) !== NoMode
1041
- ) {
1042
- workInProgress.flags |= MountLayoutDev | Update;
1043
- } else {
1044
- workInProgress.flags |= Update;
1045
- }
1012
+ workInProgress.flags |= Update;
1013
}
1014
1015
// If shouldComponentUpdate returned false, we should still update the
packages/react-reconciler/src/ReactFiberCommitWork.old.js
-115
@@ -35,7 +35,6 @@ import {
35
enableFundamentalAPI,
36
enableSuspenseCallback,
37
enableScopeAPI,
38
- enableDoubleInvokingEffects,
38
} from 'shared/ReactFeatureFlags';
39
import {
40
FunctionComponent,
@@ -1799,116 +1798,6 @@ function commitResetTextContent(current: Fiber) {
1798
resetTextContent(current.stateNode);
1799
}
1800
1802
-function invokeLayoutEffectMountInDEV(fiber: Fiber): void {
1803
- if (__DEV__ && enableDoubleInvokingEffects) {
1804
- switch (fiber.tag) {
1805
- case FunctionComponent:
1806
- case ForwardRef:
1807
- case SimpleMemoComponent: {
1808
- invokeGuardedCallback(
1809
- null,
1810
- commitHookEffectListMount,
1811
- null,
1812
- HookLayout | HookHasEffect,
1813
- fiber,
1814
- );
1815
- if (hasCaughtError()) {
1816
- const mountError = clearCaughtError();
1817
- captureCommitPhaseError(fiber, mountError);
1818
- }
1819
- break;
1820
- }
1821
- case ClassComponent: {
1822
- const instance = fiber.stateNode;
1823
- invokeGuardedCallback(null, instance.componentDidMount, instance);
1824
- if (hasCaughtError()) {
1825
- const mountError = clearCaughtError();
1826
- captureCommitPhaseError(fiber, mountError);
1827
- }
1828
- break;
1829
- }
1830
- }
1831
- }
1832
-}
1833
-
1834
-function invokePassiveEffectMountInDEV(fiber: Fiber): void {
1835
- if (__DEV__ && enableDoubleInvokingEffects) {
1836
- switch (fiber.tag) {
1837
- case FunctionComponent:
1838
- case ForwardRef:
1839
- case SimpleMemoComponent: {
1840
- invokeGuardedCallback(
1841
- null,
1842
- commitHookEffectListMount,
1843
- null,
1844
- HookPassive | HookHasEffect,
1845
- fiber,
1846
- );
1847
- if (hasCaughtError()) {
1848
- const mountError = clearCaughtError();
1849
- captureCommitPhaseError(fiber, mountError);
1850
- }
1851
- break;
1852
- }
1853
- }
1854
- }
1855
-}
1856
-
1857
-function invokeLayoutEffectUnmountInDEV(fiber: Fiber): void {
1858
- if (__DEV__ && enableDoubleInvokingEffects) {
1859
- switch (fiber.tag) {
1860
- case FunctionComponent:
1861
- case ForwardRef:
1862
- case SimpleMemoComponent: {
1863
- invokeGuardedCallback(
1864
- null,
1865
- commitHookEffectListUnmount,
1866
- null,
1867
- HookLayout | HookHasEffect,
1868
- fiber,
1869
- fiber.return,
1870
- );
1871
- if (hasCaughtError()) {
1872
- const unmountError = clearCaughtError();
1873
- captureCommitPhaseError(fiber, unmountError);
1874
- }
1875
- break;
1876
- }
1877
- case ClassComponent: {
1878
- const instance = fiber.stateNode;
1879
- if (typeof instance.componentWillUnmount === 'function') {
1880
- safelyCallComponentWillUnmount(fiber, instance);
1881
- }
1882
- break;
1883
- }
1884
- }
1885
- }
1886
-}
1887
-
1888
-function invokePassiveEffectUnmountInDEV(fiber: Fiber): void {
1889
- if (__DEV__ && enableDoubleInvokingEffects) {
1890
- switch (fiber.tag) {
1891
- case FunctionComponent:
1892
- case ForwardRef:
1893
- case SimpleMemoComponent: {
1894
- invokeGuardedCallback(
1895
- null,
1896
- commitHookEffectListUnmount,
1897
- null,
1898
- HookPassive | HookHasEffect,
1899
- fiber,
1900
- fiber.return,
1901
- );
1902
- if (hasCaughtError()) {
1903
- const unmountError = clearCaughtError();
1904
- captureCommitPhaseError(fiber, unmountError);
1905
- }
1906
- break;
1907
- }
1908
- }
1909
- }
1910
-}
1911
-
1801
export {
1802
commitBeforeMutationLifeCycles,
1803
commitResetTextContent,
@@ -1918,8 +1807,4 @@ export {
1807
commitLifeCycles,
1808
commitAttachRef,
1809
commitDetachRef,
1921
- invokeLayoutEffectMountInDEV,
1922
- invokeLayoutEffectUnmountInDEV,
1923
- invokePassiveEffectMountInDEV,
1924
- invokePassiveEffectUnmountInDEV,
1810
};
packages/react-reconciler/src/ReactFiberHooks.old.js
+16
-87
@@ -28,15 +28,9 @@ import {
28
enableCache,
29
decoupleUpdatePriorityFromScheduler,
30
enableUseRefAccessWarning,
31
- enableDoubleInvokingEffects,
31
} from 'shared/ReactFeatureFlags';
32
34
-import {
35
- NoMode,
36
- BlockingMode,
37
- DebugTracingMode,
38
- StrictMode,
39
-} from './ReactTypeOfMode';
33
+import {NoMode, BlockingMode, DebugTracingMode} from './ReactTypeOfMode';
34
import {
35
NoLane,
36
NoLanes,
@@ -55,8 +49,6 @@ import {readContext} from './ReactFiberNewContext.old';
49
import {
50
Update as UpdateEffect,
51
Passive as PassiveEffect,
58
- MountLayoutDev as MountLayoutDevEffect,
59
- MountPassiveDev as MountPassiveDevEffect,
52
} from './ReactFiberFlags';
53
import {
54
HasEffect as HookHasEffect,
@@ -475,20 +467,7 @@ export function bailoutHooks(
467
lanes: Lanes,
468
) {
469
workInProgress.updateQueue = current.updateQueue;
478
- if (
479
- __DEV__ &&
480
- enableDoubleInvokingEffects &&
481
- (workInProgress.mode & StrictMode) !== NoMode
482
- ) {
483
- workInProgress.flags &= ~(
484
- MountLayoutDevEffect |
485
- MountPassiveDevEffect |
486
- PassiveEffect |
487
- UpdateEffect
488
- );
489
- } else {
490
- workInProgress.flags &= ~(PassiveEffect | UpdateEffect);
491
- }
470
+ workInProgress.flags &= ~(PassiveEffect | UpdateEffect);
471
current.lanes = removeLanes(current.lanes, lanes);
472
}
473
@@ -1324,26 +1303,12 @@ function mountEffect(
1303
warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber);
1304
}
1305
}
1327
-
1328
- if (
1329
- __DEV__ &&
1330
- enableDoubleInvokingEffects &&
1331
- (currentlyRenderingFiber.mode & StrictMode) !== NoMode
1332
- ) {
1333
- return mountEffectImpl(
1334
- UpdateEffect | PassiveEffect | MountPassiveDevEffect,
1335
- HookPassive,
1336
- create,
1337
- deps,
1338
- );
1339
- } else {
1340
- return mountEffectImpl(
1341
- UpdateEffect | PassiveEffect,
1342
- HookPassive,
1343
- create,
1344
- deps,
1345
- );
1346
- }
1306
+ return mountEffectImpl(
1307
+ UpdateEffect | PassiveEffect,
1308
+ HookPassive,
1309
+ create,
1310
+ deps,
1311
+ );
1312
}
1313
1314
function updateEffect(
@@ -1368,20 +1333,7 @@ function mountLayoutEffect(
1333
create: () => (() => void) | void,
1334
deps: Array<mixed> | void | null,
1335
): void {
1371
- if (
1372
- __DEV__ &&
1373
- enableDoubleInvokingEffects &&
1374
- (currentlyRenderingFiber.mode & StrictMode) !== NoMode
1375
- ) {
1376
- return mountEffectImpl(
1377
- UpdateEffect | MountLayoutDevEffect,
1378
- HookLayout,
1379
- create,
1380
- deps,
1381
- );
1382
- } else {
1383
- return mountEffectImpl(UpdateEffect, HookLayout, create, deps);
1384
- }
1336
+ return mountEffectImpl(UpdateEffect, HookLayout, create, deps);
1337
}
1338
1339
function updateLayoutEffect(
@@ -1440,25 +1392,12 @@ function mountImperativeHandle<T>(
1392
const effectDeps =
1393
deps !== null && deps !== undefined ? deps.concat([ref]) : null;
1394
1443
- if (
1444
- __DEV__ &&
1445
- enableDoubleInvokingEffects &&
1446
- (currentlyRenderingFiber.mode & StrictMode) !== NoMode
1447
- ) {
1448
- return mountEffectImpl(
1449
- UpdateEffect | MountLayoutDevEffect,
1450
- HookLayout,
1451
- imperativeHandleEffect.bind(null, create, ref),
1452
- effectDeps,
1453
- );
1454
- } else {
1455
- return mountEffectImpl(
1456
- UpdateEffect,
1457
- HookLayout,
1458
- imperativeHandleEffect.bind(null, create, ref),
1459
- effectDeps,
1460
- );
1461
- }
1395
+ return mountEffectImpl(
1396
+ UpdateEffect,
1397
+ HookLayout,
1398
+ imperativeHandleEffect.bind(null, create, ref),
1399
+ effectDeps,
1400
+ );
1401
}
1402
1403
function updateImperativeHandle<T>(
@@ -1739,17 +1678,7 @@ function mountOpaqueIdentifier(): OpaqueIDType | void {
1678
const setId = mountState(id)[1];
1679
1680
if ((currentlyRenderingFiber.mode & BlockingMode) === NoMode) {
1742
- if (
1743
- __DEV__ &&
1744
- enableDoubleInvokingEffects &&
1745
- (currentlyRenderingFiber.mode & StrictMode) !== NoMode
1746
- ) {
1747
- currentlyRenderingFiber.flags |=
1748
- UpdateEffect | PassiveEffect | MountPassiveDevEffect;
1749
- } else {
1750
- currentlyRenderingFiber.flags |= UpdateEffect | PassiveEffect;
1751
- }
1752
-
1681
+ currentlyRenderingFiber.flags |= UpdateEffect | PassiveEffect;
1682
pushEffect(
1683
HookHasEffect | HookPassive,
1684
() => {
packages/react-reconciler/src/ReactFiberHydrationContext.new.js
+8
-2
@@ -24,7 +24,13 @@ import {
24
HostRoot,
25
SuspenseComponent,
26
} from './ReactWorkTags';
27
-import {Deletion, ChildDeletion, Placement, Hydrating} from './ReactFiberFlags';
27
+import {
28
+ Deletion,
29
+ ChildDeletion,
30
+ Placement,
31
+ Hydrating,
32
+ StaticMask,
33
+} from './ReactFiberFlags';
34
import invariant from 'shared/invariant';
35
36
import {
@@ -124,7 +130,7 @@ function deleteHydratableInstance(
130
const childToDelete = createFiberFromHostInstanceForDeletion();
131
childToDelete.stateNode = instance;
132
childToDelete.return = returnFiber;
127
- childToDelete.flags = Deletion;
133
+ childToDelete.flags = (childToDelete.flags & StaticMask) | Deletion;
134
135
// This might seem like it belongs on progressedFirstDeletion. However,
136
// these children are not part of the reconciliation list of children.
packages/react-reconciler/src/ReactFiberHydrationContext.old.js
+8
-2
@@ -24,7 +24,13 @@ import {
24
HostRoot,
25
SuspenseComponent,
26
} from './ReactWorkTags';
27
-import {Deletion, ChildDeletion, Placement, Hydrating} from './ReactFiberFlags';
27
+import {
28
+ Deletion,
29
+ ChildDeletion,
30
+ Placement,
31
+ Hydrating,
32
+ StaticMask,
33
+} from './ReactFiberFlags';
34
import invariant from 'shared/invariant';
35
36
import {
@@ -124,7 +130,7 @@ function deleteHydratableInstance(
130
const childToDelete = createFiberFromHostInstanceForDeletion();
131
childToDelete.stateNode = instance;
132
childToDelete.return = returnFiber;
127
- childToDelete.flags = Deletion;
133
+ childToDelete.flags = (childToDelete.flags & StaticMask) | Deletion;
134
135
// This might seem like it belongs on progressedFirstDeletion. However,
136
// these children are not part of the reconciliation list of children.
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+21
-80
@@ -14,7 +14,6 @@ import type {ReactPriorityLevel} from './ReactInternalTypes';
14
import type {Interaction} from 'scheduler/src/Tracing';
15
import type {SuspenseState} from './ReactFiberSuspenseComponent.old';
16
import type {Effect as HookEffect} from './ReactFiberHooks.old';
17
-import type {Flags} from './ReactFiberFlags';
17
import type {StackCursor} from './ReactFiberStack.old';
18
19
import {
@@ -32,7 +31,6 @@ import {
31
enableDebugTracing,
32
enableSchedulingProfiler,
33
enableScopeAPI,
35
- enableDoubleInvokingEffects,
34
disableSchedulerTimeoutInWorkLoop,
35
} from 'shared/ReactFeatureFlags';
36
import ReactSharedInternals from 'shared/ReactSharedInternals';
@@ -134,8 +132,6 @@ import {
132
HostEffectMask,
133
Hydrating,
134
HydratingAndUpdate,
137
- MountPassiveDev,
138
- MountLayoutDev,
135
} from './ReactFiberFlags';
136
import {
137
NoLanePriority,
@@ -196,10 +192,6 @@ import {
192
commitPassiveEffectDurations,
193
commitResetTextContent,
194
isSuspenseBoundaryBeingHidden,
199
- invokeLayoutEffectMountInDEV,
200
- invokePassiveEffectMountInDEV,
201
- invokeLayoutEffectUnmountInDEV,
202
- invokePassiveEffectUnmountInDEV,
195
} from './ReactFiberCommitWork.old';
196
import {enqueueUpdate} from './ReactUpdateQueue.old';
197
import {resetContextDependencies} from './ReactFiberNewContext.old';
@@ -2134,10 +2126,6 @@ function commitRootImpl(root, renderPriorityLevel) {
2126
pendingPassiveEffectsLanes = lanes;
2127
pendingPassiveEffectsRenderPriority = renderPriorityLevel;
2128
} else {
2137
- if (__DEV__ && enableDoubleInvokingEffects) {
2138
- commitDoubleInvokeEffectsInDEV(root, false);
2139
- }
2140
-
2129
// We are done with the effect chain at this point so let's clear the
2130
// nextEffect pointers to assist with GC. If we have passive effects, we'll
2131
// clear this in flushPassiveEffects.
@@ -2685,29 +2673,6 @@ function flushPassiveEffectsImpl() {
2673
}
2674
}
2675
2688
- if (enableProfilerTimer && enableProfilerCommitHooks) {
2689
- const profilerEffects = pendingPassiveProfilerEffects;
2690
- pendingPassiveProfilerEffects = [];
2691
- for (let i = 0; i < profilerEffects.length; i++) {
2692
- const fiber = ((profilerEffects[i]: any): Fiber);
2693
- commitPassiveEffectDurations(root, fiber);
2694
- }
2695
- }
2696
-
2697
- if (__DEV__) {
2698
- if (enableDebugTracing) {
2699
- logPassiveEffectsStopped();
2700
- }
2701
- }
2702
-
2703
- if (enableSchedulingProfiler) {
2704
- markPassiveEffectsStopped();
2705
- }
2706
-
2707
- if (__DEV__ && enableDoubleInvokingEffects) {
2708
- commitDoubleInvokeEffectsInDEV(root, true);
2709
- }
2710
-
2676
// Note: This currently assumes there are no passive effects on the root fiber
2677
// because the root is not part of its own effect list.
2678
// This could change in the future.
@@ -2722,8 +2687,13 @@ function flushPassiveEffectsImpl() {
2687
effect = nextNextEffect;
2688
}
2689
2725
- if (__DEV__) {
2726
- isFlushingPassiveEffects = false;
2690
+ if (enableProfilerTimer && enableProfilerCommitHooks) {
2691
+ const profilerEffects = pendingPassiveProfilerEffects;
2692
+ pendingPassiveProfilerEffects = [];
2693
+ for (let i = 0; i < profilerEffects.length; i++) {
2694
+ const fiber = ((profilerEffects[i]: any): Fiber);
2695
+ commitPassiveEffectDurations(root, fiber);
2696
+ }
2697
}
2698
2699
if (enableSchedulerTracing) {
@@ -2731,6 +2701,20 @@ function flushPassiveEffectsImpl() {
2701
finishPendingInteractions(root, lanes);
2702
}
2703
2704
+ if (__DEV__) {
2705
+ isFlushingPassiveEffects = false;
2706
+ }
2707
+
2708
+ if (__DEV__) {
2709
+ if (enableDebugTracing) {
2710
+ logPassiveEffectsStopped();
2711
+ }
2712
+ }
2713
+
2714
+ if (enableSchedulingProfiler) {
2715
+ markPassiveEffectsStopped();
2716
+ }
2717
+
2718
executionContext = prevExecutionContext;
2719
2720
flushSyncCallbackQueue();
@@ -3014,49 +2998,6 @@ function flushRenderPhaseStrictModeWarningsInDEV() {
2998
}
2999
}
3000
3017
-function commitDoubleInvokeEffectsInDEV(
3018
- root: FiberRoot,
3019
- hasPassiveEffects: boolean,
3020
-) {
3021
- if (__DEV__ && enableDoubleInvokingEffects) {
3022
- invokeEffectsInDev(root, MountLayoutDev, invokeLayoutEffectUnmountInDEV);
3023
- if (hasPassiveEffects) {
3024
- invokeEffectsInDev(
3025
- root,
3026
- MountPassiveDev,
3027
- invokePassiveEffectUnmountInDEV,
3028
- );
3029
- }
3030
-
3031
- invokeEffectsInDev(root, MountLayoutDev, invokeLayoutEffectMountInDEV);
3032
- if (hasPassiveEffects) {
3033
- invokeEffectsInDev(root, MountPassiveDev, invokePassiveEffectMountInDEV);
3034
- }
3035
- }
3036
-}
3037
-
3038
-function invokeEffectsInDev(
3039
- root: FiberRoot,
3040
- fiberFlags: Flags,
3041
- invokeEffectFn: (fiber: Fiber) => void,
3042
-): void {
3043
- if (__DEV__ && enableDoubleInvokingEffects) {
3044
- // Note: This currently assumes there are no passive effects on the root fiber
3045
- // because the root is not part of its own effect list.
3046
- // This could change in the future.
3047
- let currentEffect = root.current.firstEffect;
3048
- while (currentEffect !== null) {
3049
- const flags = currentEffect.flags;
3050
- if ((flags & fiberFlags) !== NoFlags) {
3051
- setCurrentDebugFiberInDEV(currentEffect);
3052
- invokeEffectFn(currentEffect);
3053
- resetCurrentDebugFiberInDEV();
3054
- }
3055
- currentEffect = currentEffect.nextEffect;
3056
- }
3057
- }
3058
-}
3059
-
3001
let didWarnStateUpdateForNotYetMountedComponent: Set<string> | null = null;
3002
function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) {
3003
if (__DEV__) {
packages/react-reconciler/src/__tests__/ReactDoubleInvokeEvents-test.internal.js
+2
-3
@@ -15,9 +15,8 @@ let ReactNoop;
15
let Scheduler;
16
17
function shouldDoubleInvokingEffects() {
18
- // For now, this feature only exists in the old fork (while the new fork is being bisected).
19
- // Eventually we'll land it in both forks.
20
- return __DEV__ && !__VARIANT__;
18
+ // Reverted temporarily. Need to re-land.
19
+ return false;
20
}
21
22
describe('ReactDoubleInvokeEvents', () => {
packages/react-reconciler/src/__tests__/ReactDoubleInvokeEvents-test.js
+3
-1
@@ -26,7 +26,9 @@ describe('ReactDoubleInvokeEvents', () => {
26
function supportsDoubleInvokeEffects() {
27
return gate(
28
flags =>
29
- flags.build === 'development' && flags.enableDoubleInvokingEffects,
29
+ flags.build === 'development' &&
30
+ flags.enableDoubleInvokingEffects &&
31
+ flags.dfsEffectsRefactor,
32
);
33
}
34
packages/react/src/__tests__/ReactProfiler-test.internal.js
+4
-6
@@ -4874,8 +4874,10 @@ describe('Profiler', () => {
4874
});
4875
4876
if (__DEV__) {
4877
+ // @gate dfsEffectsRefactor
4878
+ // @gate enableDoubleInvokingEffects
4879
it('double invoking does not disconnect wrapped async work', () => {
4878
- ReactFeatureFlags.enableDoubleInvokingEffects = !__VARIANT__;
4880
+ ReactFeatureFlags.enableDoubleInvokingEffects = true;
4881
4882
const callback = jest.fn(() => {
4883
const wrappedInteractions = SchedulerTracing.unstable_getCurrent();
@@ -4913,11 +4915,7 @@ describe('Profiler', () => {
4915
4916
jest.runAllTimers();
4917
4916
- if (ReactFeatureFlags.enableDoubleInvokingEffects) {
4917
- expect(callback).toHaveBeenCalledTimes(4); // 2x per effect
4918
- } else {
4919
- expect(callback).toHaveBeenCalledTimes(2);
4920
- }
4918
+ expect(callback).toHaveBeenCalledTimes(4); // 2x per effect
4919
4920
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
4921
});