Skip to content

Commit 1e748b4

Browse files
authored
Land enableLazyElements flag (#24407)
This flag is already enabled on all relevant surfaces. We can remove it.
1 parent 4175f05 commit 1e748b4

13 files changed

+68
-118
lines changed

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

+31-48
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ import {
2323
} from 'shared/ReactSymbols';
2424
import {ClassComponent, HostText, HostPortal, Fragment} from './ReactWorkTags';
2525
import isArray from 'shared/isArray';
26-
import {
27-
warnAboutStringRefs,
28-
enableLazyElements,
29-
} from 'shared/ReactFeatureFlags';
26+
import {warnAboutStringRefs} from 'shared/ReactFeatureFlags';
3027
import {checkPropStringCoercion} from 'shared/CheckStringCoercion';
3128

3229
import {
@@ -414,8 +411,7 @@ function ChildReconciler(shouldTrackSideEffects) {
414411
// We need to do this after the Hot Reloading check above,
415412
// because hot reloading has different semantics than prod because
416413
// it doesn't resuspend. So we can't let the call below suspend.
417-
(enableLazyElements &&
418-
typeof elementType === 'object' &&
414+
(typeof elementType === 'object' &&
419415
elementType !== null &&
420416
elementType.$$typeof === REACT_LAZY_TYPE &&
421417
resolveLazy(elementType) === current.type)
@@ -530,11 +526,9 @@ function ChildReconciler(shouldTrackSideEffects) {
530526
return created;
531527
}
532528
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);
538532
}
539533
}
540534

@@ -601,11 +595,9 @@ function ChildReconciler(shouldTrackSideEffects) {
601595
}
602596
}
603597
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);
609601
}
610602
}
611603

@@ -663,17 +655,15 @@ function ChildReconciler(shouldTrackSideEffects) {
663655
return updatePortal(returnFiber, matchedFiber, newChild, lanes);
664656
}
665657
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+
);
677667
}
678668

679669
if (isArray(newChild) || getIteratorFn(newChild)) {
@@ -732,14 +722,10 @@ function ChildReconciler(shouldTrackSideEffects) {
732722
);
733723
break;
734724
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;
743729
default:
744730
break;
745731
}
@@ -1175,8 +1161,7 @@ function ChildReconciler(shouldTrackSideEffects) {
11751161
// We need to do this after the Hot Reloading check above,
11761162
// because hot reloading has different semantics than prod because
11771163
// it doesn't resuspend. So we can't let the call below suspend.
1178-
(enableLazyElements &&
1179-
typeof elementType === 'object' &&
1164+
(typeof elementType === 'object' &&
11801165
elementType !== null &&
11811166
elementType.$$typeof === REACT_LAZY_TYPE &&
11821167
resolveLazy(elementType) === child.type)
@@ -1302,17 +1287,15 @@ function ChildReconciler(shouldTrackSideEffects) {
13021287
),
13031288
);
13041289
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+
);
13161299
}
13171300

13181301
if (isArray(newChild)) {

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

+31-48
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ import {
2323
} from 'shared/ReactSymbols';
2424
import {ClassComponent, HostText, HostPortal, Fragment} from './ReactWorkTags';
2525
import isArray from 'shared/isArray';
26-
import {
27-
warnAboutStringRefs,
28-
enableLazyElements,
29-
} from 'shared/ReactFeatureFlags';
26+
import {warnAboutStringRefs} from 'shared/ReactFeatureFlags';
3027
import {checkPropStringCoercion} from 'shared/CheckStringCoercion';
3128

3229
import {
@@ -414,8 +411,7 @@ function ChildReconciler(shouldTrackSideEffects) {
414411
// We need to do this after the Hot Reloading check above,
415412
// because hot reloading has different semantics than prod because
416413
// it doesn't resuspend. So we can't let the call below suspend.
417-
(enableLazyElements &&
418-
typeof elementType === 'object' &&
414+
(typeof elementType === 'object' &&
419415
elementType !== null &&
420416
elementType.$$typeof === REACT_LAZY_TYPE &&
421417
resolveLazy(elementType) === current.type)
@@ -530,11 +526,9 @@ function ChildReconciler(shouldTrackSideEffects) {
530526
return created;
531527
}
532528
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);
538532
}
539533
}
540534

@@ -601,11 +595,9 @@ function ChildReconciler(shouldTrackSideEffects) {
601595
}
602596
}
603597
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);
609601
}
610602
}
611603

@@ -663,17 +655,15 @@ function ChildReconciler(shouldTrackSideEffects) {
663655
return updatePortal(returnFiber, matchedFiber, newChild, lanes);
664656
}
665657
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+
);
677667
}
678668

679669
if (isArray(newChild) || getIteratorFn(newChild)) {
@@ -732,14 +722,10 @@ function ChildReconciler(shouldTrackSideEffects) {
732722
);
733723
break;
734724
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;
743729
default:
744730
break;
745731
}
@@ -1175,8 +1161,7 @@ function ChildReconciler(shouldTrackSideEffects) {
11751161
// We need to do this after the Hot Reloading check above,
11761162
// because hot reloading has different semantics than prod because
11771163
// it doesn't resuspend. So we can't let the call below suspend.
1178-
(enableLazyElements &&
1179-
typeof elementType === 'object' &&
1164+
(typeof elementType === 'object' &&
11801165
elementType !== null &&
11811166
elementType.$$typeof === REACT_LAZY_TYPE &&
11821167
resolveLazy(elementType) === child.type)
@@ -1302,17 +1287,15 @@ function ChildReconciler(shouldTrackSideEffects) {
13021287
),
13031288
);
13041289
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+
);
13161299
}
13171300

13181301
if (isArray(newChild)) {

packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js

-4
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,6 @@ describe('ReactLazy', () => {
12681268
expect(componentStackMessage).toContain('in Lazy');
12691269
});
12701270

1271-
// @gate enableLazyElements
12721271
it('mount and reorder lazy types', async () => {
12731272
class Child extends React.Component {
12741273
componentWillUnmount() {
@@ -1385,7 +1384,6 @@ describe('ReactLazy', () => {
13851384
expect(root).toMatchRenderedOutput('ba');
13861385
});
13871386

1388-
// @gate enableLazyElements
13891387
it('mount and reorder lazy types (legacy mode)', async () => {
13901388
class Child extends React.Component {
13911389
componentDidMount() {
@@ -1474,7 +1472,6 @@ describe('ReactLazy', () => {
14741472
expect(root).toMatchRenderedOutput('ba');
14751473
});
14761474

1477-
// @gate enableLazyElements
14781475
it('mount and reorder lazy elements', async () => {
14791476
class Child extends React.Component {
14801477
componentDidMount() {
@@ -1556,7 +1553,6 @@ describe('ReactLazy', () => {
15561553
expect(root).toMatchRenderedOutput('ba');
15571554
});
15581555

1559-
// @gate enableLazyElements
15601556
it('mount and reorder lazy elements (legacy mode)', async () => {
15611557
class Child extends React.Component {
15621558
componentDidMount() {

packages/react-server/src/ReactFizzServer.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ import {
113113
disableModulePatternComponents,
114114
warnAboutDefaultPropsOnFunctionComponents,
115115
enableScopeAPI,
116-
enableLazyElements,
117116
enableSuspenseAvoidThisFallbackFizz,
118117
} from 'shared/ReactFeatureFlags';
119118

@@ -1162,14 +1161,12 @@ function renderNodeDestructive(
11621161
);
11631162
// eslint-disable-next-line-no-fallthrough
11641163
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;
11731170
}
11741171
}
11751172

packages/shared/ReactFeatureFlags.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
export const enableSuspenseServerRenderer = true;
1717
export const enableSelectiveHydration = true;
1818
export const warnAboutDeprecatedLifecycles = true;
19-
export const enableLazyElements = true;
2019
export const enableComponentStackLocations = true;
2120
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
2221
export const enablePersistentOffscreenHostContainer = false;

packages/shared/forks/ReactFeatureFlags.native-fb.js

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
2828
export const enableUpdaterTracking = __PROFILE__;
2929
export const enableSuspenseServerRenderer = false;
3030
export const enableSelectiveHydration = false;
31-
export const enableLazyElements = false;
3231
export const enableCache = false;
3332
export const enableCacheElement = true;
3433
export const enableSchedulerDebugging = false;

packages/shared/forks/ReactFeatureFlags.native-oss.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = __PROFILE__;
2323
export const enableSuspenseServerRenderer = false;
2424
export const enableSelectiveHydration = false;
25-
export const enableLazyElements = false;
2625
export const enableCache = false;
2726
export const enableCacheElement = false;
2827
export const disableJavaScriptURLs = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
2323
export const enableSuspenseServerRenderer = false;
2424
export const enableSelectiveHydration = false;
25-
export const enableLazyElements = false;
2625
export const enableCache = __EXPERIMENTAL__;
2726
export const enableCacheElement = __EXPERIMENTAL__;
2827
export const disableJavaScriptURLs = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.native.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
2323
export const enableSuspenseServerRenderer = false;
2424
export const enableSelectiveHydration = false;
25-
export const enableLazyElements = false;
2625
export const enableCache = true;
2726
export const enableCacheElement = true;
2827
export const disableJavaScriptURLs = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
2323
export const enableSuspenseServerRenderer = false;
2424
export const enableSelectiveHydration = false;
25-
export const enableLazyElements = false;
2625
export const enableCache = true;
2726
export const enableCacheElement = true;
2827
export const enableSchedulerDebugging = false;

packages/shared/forks/ReactFeatureFlags.testing.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
2323
export const enableSuspenseServerRenderer = false;
2424
export const enableSelectiveHydration = false;
25-
export const enableLazyElements = false;
2625
export const enableCache = __EXPERIMENTAL__;
2726
export const enableCacheElement = __EXPERIMENTAL__;
2827
export const disableJavaScriptURLs = false;

packages/shared/forks/ReactFeatureFlags.testing.www.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false;
2222
export const enableUpdaterTracking = false;
2323
export const enableSuspenseServerRenderer = true;
2424
export const enableSelectiveHydration = true;
25-
export const enableLazyElements = false;
2625
export const enableCache = true;
2726
export const enableCacheElement = true;
2827
export const disableJavaScriptURLs = true;

0 commit comments

Comments
 (0)