Land enableLazyElements flag (#24407)
This flag is already enabled on all relevant surfaces. We can remove it.
Andrew Clark committed
Apr 20, 2022 at 10:17 UTC
1e748b4528cec1e5e8c8413f8b2e9bcde999d981
13 files changed
+68
-118
packages/react-reconciler/src/ReactChildFiber.new.js
+31
-48
@@ -23,10 +23,7 @@ import {
23
} from 'shared/ReactSymbols';
24
import {ClassComponent, HostText, HostPortal, Fragment} from './ReactWorkTags';
25
import isArray from 'shared/isArray';
26
-import {
27
- warnAboutStringRefs,
28
- enableLazyElements,
29
-} from 'shared/ReactFeatureFlags';
26
+import {warnAboutStringRefs} from 'shared/ReactFeatureFlags';
27
import {checkPropStringCoercion} from 'shared/CheckStringCoercion';
28
29
import {
@@ -414,8 +411,7 @@ function ChildReconciler(shouldTrackSideEffects) {
411
// We need to do this after the Hot Reloading check above,
412
// because hot reloading has different semantics than prod because
413
// it doesn't resuspend. So we can't let the call below suspend.
417
- (enableLazyElements &&
418
- typeof elementType === 'object' &&
414
+ (typeof elementType === 'object' &&
415
elementType !== null &&
416
elementType.$$typeof === REACT_LAZY_TYPE &&
417
resolveLazy(elementType) === current.type)
@@ -530,11 +526,9 @@ function ChildReconciler(shouldTrackSideEffects) {
526
return created;
527
}
528
case REACT_LAZY_TYPE: {
533
- if (enableLazyElements) {
534
- const payload = newChild._payload;
535
- const init = newChild._init;
536
- return createChild(returnFiber, init(payload), lanes);
537
- }
529
+ const payload = newChild._payload;
530
+ const init = newChild._init;
531
+ return createChild(returnFiber, init(payload), lanes);
532
}
533
}
534
@@ -601,11 +595,9 @@ function ChildReconciler(shouldTrackSideEffects) {
595
}
596
}
597
case REACT_LAZY_TYPE: {
604
- if (enableLazyElements) {
605
- const payload = newChild._payload;
606
- const init = newChild._init;
607
- return updateSlot(returnFiber, oldFiber, init(payload), lanes);
608
- }
598
+ const payload = newChild._payload;
599
+ const init = newChild._init;
600
+ return updateSlot(returnFiber, oldFiber, init(payload), lanes);
601
}
602
}
603
@@ -663,17 +655,15 @@ function ChildReconciler(shouldTrackSideEffects) {
655
return updatePortal(returnFiber, matchedFiber, newChild, lanes);
656
}
657
case REACT_LAZY_TYPE:
666
- if (enableLazyElements) {
667
- const payload = newChild._payload;
668
- const init = newChild._init;
669
- return updateFromMap(
670
- existingChildren,
671
- returnFiber,
672
- newIdx,
673
- init(payload),
674
- lanes,
675
- );
676
- }
658
+ const payload = newChild._payload;
659
+ const init = newChild._init;
660
+ return updateFromMap(
661
+ existingChildren,
662
+ returnFiber,
663
+ newIdx,
664
+ init(payload),
665
+ lanes,
666
+ );
667
}
668
669
if (isArray(newChild) || getIteratorFn(newChild)) {
@@ -732,14 +722,10 @@ function ChildReconciler(shouldTrackSideEffects) {
722
);
723
break;
724
case REACT_LAZY_TYPE:
735
- if (enableLazyElements) {
736
- const payload = child._payload;
737
- const init = (child._init: any);
738
- warnOnInvalidKey(init(payload), knownKeys, returnFiber);
739
- break;
740
- }
741
- // We intentionally fallthrough here if enableLazyElements is not on.
742
- // eslint-disable-next-lined no-fallthrough
725
+ const payload = child._payload;
726
+ const init = (child._init: any);
727
+ warnOnInvalidKey(init(payload), knownKeys, returnFiber);
728
+ break;
729
default:
730
break;
731
}
@@ -1175,8 +1161,7 @@ function ChildReconciler(shouldTrackSideEffects) {
1161
// We need to do this after the Hot Reloading check above,
1162
// because hot reloading has different semantics than prod because
1163
// it doesn't resuspend. So we can't let the call below suspend.
1178
- (enableLazyElements &&
1179
- typeof elementType === 'object' &&
1164
+ (typeof elementType === 'object' &&
1165
elementType !== null &&
1166
elementType.$$typeof === REACT_LAZY_TYPE &&
1167
resolveLazy(elementType) === child.type)
@@ -1302,17 +1287,15 @@ function ChildReconciler(shouldTrackSideEffects) {
1287
),
1288
);
1289
case REACT_LAZY_TYPE:
1305
- if (enableLazyElements) {
1306
- const payload = newChild._payload;
1307
- const init = newChild._init;
1308
- // TODO: This function is supposed to be non-recursive.
1309
- return reconcileChildFibers(
1310
- returnFiber,
1311
- currentFirstChild,
1312
- init(payload),
1313
- lanes,
1314
- );
1315
- }
1290
+ const payload = newChild._payload;
1291
+ const init = newChild._init;
1292
+ // TODO: This function is supposed to be non-recursive.
1293
+ return reconcileChildFibers(
1294
+ returnFiber,
1295
+ currentFirstChild,
1296
+ init(payload),
1297
+ lanes,
1298
+ );
1299
}
1300
1301
if (isArray(newChild)) {
packages/react-reconciler/src/ReactChildFiber.old.js
+31
-48
@@ -23,10 +23,7 @@ import {
23
} from 'shared/ReactSymbols';
24
import {ClassComponent, HostText, HostPortal, Fragment} from './ReactWorkTags';
25
import isArray from 'shared/isArray';
26
-import {
27
- warnAboutStringRefs,
28
- enableLazyElements,
29
-} from 'shared/ReactFeatureFlags';
26
+import {warnAboutStringRefs} from 'shared/ReactFeatureFlags';
27
import {checkPropStringCoercion} from 'shared/CheckStringCoercion';
28
29
import {
@@ -414,8 +411,7 @@ function ChildReconciler(shouldTrackSideEffects) {
411
// We need to do this after the Hot Reloading check above,
412
// because hot reloading has different semantics than prod because
413
// it doesn't resuspend. So we can't let the call below suspend.
417
- (enableLazyElements &&
418
- typeof elementType === 'object' &&
414
+ (typeof elementType === 'object' &&
415
elementType !== null &&
416
elementType.$$typeof === REACT_LAZY_TYPE &&
417
resolveLazy(elementType) === current.type)
@@ -530,11 +526,9 @@ function ChildReconciler(shouldTrackSideEffects) {
526
return created;
527
}
528
case REACT_LAZY_TYPE: {
533
- if (enableLazyElements) {
534
- const payload = newChild._payload;
535
- const init = newChild._init;
536
- return createChild(returnFiber, init(payload), lanes);
537
- }
529
+ const payload = newChild._payload;
530
+ const init = newChild._init;
531
+ return createChild(returnFiber, init(payload), lanes);
532
}
533
}
534
@@ -601,11 +595,9 @@ function ChildReconciler(shouldTrackSideEffects) {
595
}
596
}
597
case REACT_LAZY_TYPE: {
604
- if (enableLazyElements) {
605
- const payload = newChild._payload;
606
- const init = newChild._init;
607
- return updateSlot(returnFiber, oldFiber, init(payload), lanes);
608
- }
598
+ const payload = newChild._payload;
599
+ const init = newChild._init;
600
+ return updateSlot(returnFiber, oldFiber, init(payload), lanes);
601
}
602
}
603
@@ -663,17 +655,15 @@ function ChildReconciler(shouldTrackSideEffects) {
655
return updatePortal(returnFiber, matchedFiber, newChild, lanes);
656
}
657
case REACT_LAZY_TYPE:
666
- if (enableLazyElements) {
667
- const payload = newChild._payload;
668
- const init = newChild._init;
669
- return updateFromMap(
670
- existingChildren,
671
- returnFiber,
672
- newIdx,
673
- init(payload),
674
- lanes,
675
- );
676
- }
658
+ const payload = newChild._payload;
659
+ const init = newChild._init;
660
+ return updateFromMap(
661
+ existingChildren,
662
+ returnFiber,
663
+ newIdx,
664
+ init(payload),
665
+ lanes,
666
+ );
667
}
668
669
if (isArray(newChild) || getIteratorFn(newChild)) {
@@ -732,14 +722,10 @@ function ChildReconciler(shouldTrackSideEffects) {
722
);
723
break;
724
case REACT_LAZY_TYPE:
735
- if (enableLazyElements) {
736
- const payload = child._payload;
737
- const init = (child._init: any);
738
- warnOnInvalidKey(init(payload), knownKeys, returnFiber);
739
- break;
740
- }
741
- // We intentionally fallthrough here if enableLazyElements is not on.
742
- // eslint-disable-next-lined no-fallthrough
725
+ const payload = child._payload;
726
+ const init = (child._init: any);
727
+ warnOnInvalidKey(init(payload), knownKeys, returnFiber);
728
+ break;
729
default:
730
break;
731
}
@@ -1175,8 +1161,7 @@ function ChildReconciler(shouldTrackSideEffects) {
1161
// We need to do this after the Hot Reloading check above,
1162
// because hot reloading has different semantics than prod because
1163
// it doesn't resuspend. So we can't let the call below suspend.
1178
- (enableLazyElements &&
1179
- typeof elementType === 'object' &&
1164
+ (typeof elementType === 'object' &&
1165
elementType !== null &&
1166
elementType.$$typeof === REACT_LAZY_TYPE &&
1167
resolveLazy(elementType) === child.type)
@@ -1302,17 +1287,15 @@ function ChildReconciler(shouldTrackSideEffects) {
1287
),
1288
);
1289
case REACT_LAZY_TYPE:
1305
- if (enableLazyElements) {
1306
- const payload = newChild._payload;
1307
- const init = newChild._init;
1308
- // TODO: This function is supposed to be non-recursive.
1309
- return reconcileChildFibers(
1310
- returnFiber,
1311
- currentFirstChild,
1312
- init(payload),
1313
- lanes,
1314
- );
1315
- }
1290
+ const payload = newChild._payload;
1291
+ const init = newChild._init;
1292
+ // TODO: This function is supposed to be non-recursive.
1293
+ return reconcileChildFibers(
1294
+ returnFiber,
1295
+ currentFirstChild,
1296
+ init(payload),
1297
+ lanes,
1298
+ );
1299
}
1300
1301
if (isArray(newChild)) {
packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js
-4
@@ -1268,7 +1268,6 @@ describe('ReactLazy', () => {
1268
expect(componentStackMessage).toContain('in Lazy');
1269
});
1270
1271
- // @gate enableLazyElements
1271
it('mount and reorder lazy types', async () => {
1272
class Child extends React.Component {
1273
componentWillUnmount() {
@@ -1385,7 +1384,6 @@ describe('ReactLazy', () => {
1384
expect(root).toMatchRenderedOutput('ba');
1385
});
1386
1388
- // @gate enableLazyElements
1387
it('mount and reorder lazy types (legacy mode)', async () => {
1388
class Child extends React.Component {
1389
componentDidMount() {
@@ -1474,7 +1472,6 @@ describe('ReactLazy', () => {
1472
expect(root).toMatchRenderedOutput('ba');
1473
});
1474
1477
- // @gate enableLazyElements
1475
it('mount and reorder lazy elements', async () => {
1476
class Child extends React.Component {
1477
componentDidMount() {
@@ -1556,7 +1553,6 @@ describe('ReactLazy', () => {
1553
expect(root).toMatchRenderedOutput('ba');
1554
});
1555
1559
- // @gate enableLazyElements
1556
it('mount and reorder lazy elements (legacy mode)', async () => {
1557
class Child extends React.Component {
1558
componentDidMount() {
packages/react-server/src/ReactFizzServer.js
+6
-9
@@ -113,7 +113,6 @@ import {
113
disableModulePatternComponents,
114
warnAboutDefaultPropsOnFunctionComponents,
115
enableScopeAPI,
116
- enableLazyElements,
116
enableSuspenseAvoidThisFallbackFizz,
117
} from 'shared/ReactFeatureFlags';
118
@@ -1162,14 +1161,12 @@ function renderNodeDestructive(
1161
);
1162
// eslint-disable-next-line-no-fallthrough
1163
case REACT_LAZY_TYPE: {
1165
- if (enableLazyElements) {
1166
- const lazyNode: LazyComponentType<any, any> = (node: any);
1167
- const payload = lazyNode._payload;
1168
- const init = lazyNode._init;
1169
- const resolvedNode = init(payload);
1170
- renderNodeDestructive(request, task, resolvedNode);
1171
- return;
1172
- }
1164
+ const lazyNode: LazyComponentType<any, any> = (node: any);
1165
+ const payload = lazyNode._payload;
1166
+ const init = lazyNode._init;
1167
+ const resolvedNode = init(payload);
1168
+ renderNodeDestructive(request, task, resolvedNode);
1169
+ return;
1170
}
1171
}
1172
packages/shared/ReactFeatureFlags.js
-1
@@ -16,7 +16,6 @@
16
export const enableSuspenseServerRenderer = true;
17
export const enableSelectiveHydration = true;
18
export const warnAboutDeprecatedLifecycles = true;
19
-export const enableLazyElements = true;
19
export const enableComponentStackLocations = true;
20
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
21
export const enablePersistentOffscreenHostContainer = false;
packages/shared/forks/ReactFeatureFlags.native-fb.js
-1
@@ -28,7 +28,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
28
export const enableUpdaterTracking = __PROFILE__;
29
export const enableSuspenseServerRenderer = false;
30
export const enableSelectiveHydration = false;
31
-export const enableLazyElements = false;
31
export const enableCache = false;
32
export const enableCacheElement = true;
33
export const enableSchedulerDebugging = false;
packages/shared/forks/ReactFeatureFlags.native-oss.js
-1
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
22
export const enableUpdaterTracking = __PROFILE__;
23
export const enableSuspenseServerRenderer = false;
24
export const enableSelectiveHydration = false;
25
-export const enableLazyElements = false;
25
export const enableCache = false;
26
export const enableCacheElement = false;
27
export const disableJavaScriptURLs = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
-1
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
22
export const enableUpdaterTracking = false;
23
export const enableSuspenseServerRenderer = false;
24
export const enableSelectiveHydration = false;
25
-export const enableLazyElements = false;
25
export const enableCache = __EXPERIMENTAL__;
26
export const enableCacheElement = __EXPERIMENTAL__;
27
export const disableJavaScriptURLs = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
-1
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
22
export const enableUpdaterTracking = false;
23
export const enableSuspenseServerRenderer = false;
24
export const enableSelectiveHydration = false;
25
-export const enableLazyElements = false;
25
export const enableCache = true;
26
export const enableCacheElement = true;
27
export const disableJavaScriptURLs = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
-1
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
22
export const enableUpdaterTracking = false;
23
export const enableSuspenseServerRenderer = false;
24
export const enableSelectiveHydration = false;
25
-export const enableLazyElements = false;
25
export const enableCache = true;
26
export const enableCacheElement = true;
27
export const enableSchedulerDebugging = false;
packages/shared/forks/ReactFeatureFlags.testing.js
-1
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
22
export const enableUpdaterTracking = false;
23
export const enableSuspenseServerRenderer = false;
24
export const enableSelectiveHydration = false;
25
-export const enableLazyElements = false;
25
export const enableCache = __EXPERIMENTAL__;
26
export const enableCacheElement = __EXPERIMENTAL__;
27
export const disableJavaScriptURLs = false;
packages/shared/forks/ReactFeatureFlags.testing.www.js
-1
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
22
export const enableUpdaterTracking = false;
23
export const enableSuspenseServerRenderer = true;
24
export const enableSelectiveHydration = true;
25
-export const enableLazyElements = false;
25
export const enableCache = true;
26
export const enableCacheElement = true;
27
export const disableJavaScriptURLs = true;
packages/shared/forks/ReactFeatureFlags.www.js
-1
@@ -70,7 +70,6 @@ export const enableGetInspectorDataForInstanceInProduction = false;
70
export const enableSuspenseServerRenderer = true;
71
export const enableSelectiveHydration = true;
72
73
-export const enableLazyElements = true;
73
export const enableCache = true;
74
export const enableCacheElement = true;
75