diff --git a/packages/react-reconciler/src/ReactChildFiber.new.js b/packages/react-reconciler/src/ReactChildFiber.new.js index 55246de7c59b7..e7eb67328af09 100644 --- a/packages/react-reconciler/src/ReactChildFiber.new.js +++ b/packages/react-reconciler/src/ReactChildFiber.new.js @@ -23,10 +23,7 @@ import { } from 'shared/ReactSymbols'; import {ClassComponent, HostText, HostPortal, Fragment} from './ReactWorkTags'; import isArray from 'shared/isArray'; -import { - warnAboutStringRefs, - enableLazyElements, -} from 'shared/ReactFeatureFlags'; +import {warnAboutStringRefs} from 'shared/ReactFeatureFlags'; import {checkPropStringCoercion} from 'shared/CheckStringCoercion'; import { @@ -414,8 +411,7 @@ function ChildReconciler(shouldTrackSideEffects) { // We need to do this after the Hot Reloading check above, // because hot reloading has different semantics than prod because // it doesn't resuspend. So we can't let the call below suspend. - (enableLazyElements && - typeof elementType === 'object' && + (typeof elementType === 'object' && elementType !== null && elementType.$$typeof === REACT_LAZY_TYPE && resolveLazy(elementType) === current.type) @@ -530,11 +526,9 @@ function ChildReconciler(shouldTrackSideEffects) { return created; } case REACT_LAZY_TYPE: { - if (enableLazyElements) { - const payload = newChild._payload; - const init = newChild._init; - return createChild(returnFiber, init(payload), lanes); - } + const payload = newChild._payload; + const init = newChild._init; + return createChild(returnFiber, init(payload), lanes); } } @@ -601,11 +595,9 @@ function ChildReconciler(shouldTrackSideEffects) { } } case REACT_LAZY_TYPE: { - if (enableLazyElements) { - const payload = newChild._payload; - const init = newChild._init; - return updateSlot(returnFiber, oldFiber, init(payload), lanes); - } + const payload = newChild._payload; + const init = newChild._init; + return updateSlot(returnFiber, oldFiber, init(payload), lanes); } } @@ -663,17 +655,15 @@ function ChildReconciler(shouldTrackSideEffects) { return updatePortal(returnFiber, matchedFiber, newChild, lanes); } case REACT_LAZY_TYPE: - if (enableLazyElements) { - const payload = newChild._payload; - const init = newChild._init; - return updateFromMap( - existingChildren, - returnFiber, - newIdx, - init(payload), - lanes, - ); - } + const payload = newChild._payload; + const init = newChild._init; + return updateFromMap( + existingChildren, + returnFiber, + newIdx, + init(payload), + lanes, + ); } if (isArray(newChild) || getIteratorFn(newChild)) { @@ -732,14 +722,10 @@ function ChildReconciler(shouldTrackSideEffects) { ); break; case REACT_LAZY_TYPE: - if (enableLazyElements) { - const payload = child._payload; - const init = (child._init: any); - warnOnInvalidKey(init(payload), knownKeys, returnFiber); - break; - } - // We intentionally fallthrough here if enableLazyElements is not on. - // eslint-disable-next-lined no-fallthrough + const payload = child._payload; + const init = (child._init: any); + warnOnInvalidKey(init(payload), knownKeys, returnFiber); + break; default: break; } @@ -1175,8 +1161,7 @@ function ChildReconciler(shouldTrackSideEffects) { // We need to do this after the Hot Reloading check above, // because hot reloading has different semantics than prod because // it doesn't resuspend. So we can't let the call below suspend. - (enableLazyElements && - typeof elementType === 'object' && + (typeof elementType === 'object' && elementType !== null && elementType.$$typeof === REACT_LAZY_TYPE && resolveLazy(elementType) === child.type) @@ -1302,17 +1287,15 @@ function ChildReconciler(shouldTrackSideEffects) { ), ); case REACT_LAZY_TYPE: - if (enableLazyElements) { - const payload = newChild._payload; - const init = newChild._init; - // TODO: This function is supposed to be non-recursive. - return reconcileChildFibers( - returnFiber, - currentFirstChild, - init(payload), - lanes, - ); - } + const payload = newChild._payload; + const init = newChild._init; + // TODO: This function is supposed to be non-recursive. + return reconcileChildFibers( + returnFiber, + currentFirstChild, + init(payload), + lanes, + ); } if (isArray(newChild)) { diff --git a/packages/react-reconciler/src/ReactChildFiber.old.js b/packages/react-reconciler/src/ReactChildFiber.old.js index ae45c2eadcfa1..320924d6030ec 100644 --- a/packages/react-reconciler/src/ReactChildFiber.old.js +++ b/packages/react-reconciler/src/ReactChildFiber.old.js @@ -23,10 +23,7 @@ import { } from 'shared/ReactSymbols'; import {ClassComponent, HostText, HostPortal, Fragment} from './ReactWorkTags'; import isArray from 'shared/isArray'; -import { - warnAboutStringRefs, - enableLazyElements, -} from 'shared/ReactFeatureFlags'; +import {warnAboutStringRefs} from 'shared/ReactFeatureFlags'; import {checkPropStringCoercion} from 'shared/CheckStringCoercion'; import { @@ -414,8 +411,7 @@ function ChildReconciler(shouldTrackSideEffects) { // We need to do this after the Hot Reloading check above, // because hot reloading has different semantics than prod because // it doesn't resuspend. So we can't let the call below suspend. - (enableLazyElements && - typeof elementType === 'object' && + (typeof elementType === 'object' && elementType !== null && elementType.$$typeof === REACT_LAZY_TYPE && resolveLazy(elementType) === current.type) @@ -530,11 +526,9 @@ function ChildReconciler(shouldTrackSideEffects) { return created; } case REACT_LAZY_TYPE: { - if (enableLazyElements) { - const payload = newChild._payload; - const init = newChild._init; - return createChild(returnFiber, init(payload), lanes); - } + const payload = newChild._payload; + const init = newChild._init; + return createChild(returnFiber, init(payload), lanes); } } @@ -601,11 +595,9 @@ function ChildReconciler(shouldTrackSideEffects) { } } case REACT_LAZY_TYPE: { - if (enableLazyElements) { - const payload = newChild._payload; - const init = newChild._init; - return updateSlot(returnFiber, oldFiber, init(payload), lanes); - } + const payload = newChild._payload; + const init = newChild._init; + return updateSlot(returnFiber, oldFiber, init(payload), lanes); } } @@ -663,17 +655,15 @@ function ChildReconciler(shouldTrackSideEffects) { return updatePortal(returnFiber, matchedFiber, newChild, lanes); } case REACT_LAZY_TYPE: - if (enableLazyElements) { - const payload = newChild._payload; - const init = newChild._init; - return updateFromMap( - existingChildren, - returnFiber, - newIdx, - init(payload), - lanes, - ); - } + const payload = newChild._payload; + const init = newChild._init; + return updateFromMap( + existingChildren, + returnFiber, + newIdx, + init(payload), + lanes, + ); } if (isArray(newChild) || getIteratorFn(newChild)) { @@ -732,14 +722,10 @@ function ChildReconciler(shouldTrackSideEffects) { ); break; case REACT_LAZY_TYPE: - if (enableLazyElements) { - const payload = child._payload; - const init = (child._init: any); - warnOnInvalidKey(init(payload), knownKeys, returnFiber); - break; - } - // We intentionally fallthrough here if enableLazyElements is not on. - // eslint-disable-next-lined no-fallthrough + const payload = child._payload; + const init = (child._init: any); + warnOnInvalidKey(init(payload), knownKeys, returnFiber); + break; default: break; } @@ -1175,8 +1161,7 @@ function ChildReconciler(shouldTrackSideEffects) { // We need to do this after the Hot Reloading check above, // because hot reloading has different semantics than prod because // it doesn't resuspend. So we can't let the call below suspend. - (enableLazyElements && - typeof elementType === 'object' && + (typeof elementType === 'object' && elementType !== null && elementType.$$typeof === REACT_LAZY_TYPE && resolveLazy(elementType) === child.type) @@ -1302,17 +1287,15 @@ function ChildReconciler(shouldTrackSideEffects) { ), ); case REACT_LAZY_TYPE: - if (enableLazyElements) { - const payload = newChild._payload; - const init = newChild._init; - // TODO: This function is supposed to be non-recursive. - return reconcileChildFibers( - returnFiber, - currentFirstChild, - init(payload), - lanes, - ); - } + const payload = newChild._payload; + const init = newChild._init; + // TODO: This function is supposed to be non-recursive. + return reconcileChildFibers( + returnFiber, + currentFirstChild, + init(payload), + lanes, + ); } if (isArray(newChild)) { diff --git a/packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js b/packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js index 769679c9a7013..01e9742259365 100644 --- a/packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js @@ -1268,7 +1268,6 @@ describe('ReactLazy', () => { expect(componentStackMessage).toContain('in Lazy'); }); - // @gate enableLazyElements it('mount and reorder lazy types', async () => { class Child extends React.Component { componentWillUnmount() { @@ -1385,7 +1384,6 @@ describe('ReactLazy', () => { expect(root).toMatchRenderedOutput('ba'); }); - // @gate enableLazyElements it('mount and reorder lazy types (legacy mode)', async () => { class Child extends React.Component { componentDidMount() { @@ -1474,7 +1472,6 @@ describe('ReactLazy', () => { expect(root).toMatchRenderedOutput('ba'); }); - // @gate enableLazyElements it('mount and reorder lazy elements', async () => { class Child extends React.Component { componentDidMount() { @@ -1556,7 +1553,6 @@ describe('ReactLazy', () => { expect(root).toMatchRenderedOutput('ba'); }); - // @gate enableLazyElements it('mount and reorder lazy elements (legacy mode)', async () => { class Child extends React.Component { componentDidMount() { diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index 018235aae0872..d206a69e48c3d 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -113,7 +113,6 @@ import { disableModulePatternComponents, warnAboutDefaultPropsOnFunctionComponents, enableScopeAPI, - enableLazyElements, enableSuspenseAvoidThisFallbackFizz, } from 'shared/ReactFeatureFlags'; @@ -1162,14 +1161,12 @@ function renderNodeDestructive( ); // eslint-disable-next-line-no-fallthrough case REACT_LAZY_TYPE: { - if (enableLazyElements) { - const lazyNode: LazyComponentType = (node: any); - const payload = lazyNode._payload; - const init = lazyNode._init; - const resolvedNode = init(payload); - renderNodeDestructive(request, task, resolvedNode); - return; - } + const lazyNode: LazyComponentType = (node: any); + const payload = lazyNode._payload; + const init = lazyNode._init; + const resolvedNode = init(payload); + renderNodeDestructive(request, task, resolvedNode); + return; } } diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index aafe4c74d0440..f7529132aef71 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -16,7 +16,6 @@ export const enableSuspenseServerRenderer = true; export const enableSelectiveHydration = true; export const warnAboutDeprecatedLifecycles = true; -export const enableLazyElements = true; export const enableComponentStackLocations = true; export const disableSchedulerTimeoutBasedOnReactExpirationTime = false; export const enablePersistentOffscreenHostContainer = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index f2ce77374235e..91795dca3093d 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -28,7 +28,6 @@ export const enableProfilerNestedUpdateScheduledHook = false; export const enableUpdaterTracking = __PROFILE__; export const enableSuspenseServerRenderer = false; export const enableSelectiveHydration = false; -export const enableLazyElements = false; export const enableCache = false; export const enableCacheElement = true; export const enableSchedulerDebugging = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index 43855df94f90d..3d816e86143c5 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false; export const enableUpdaterTracking = __PROFILE__; export const enableSuspenseServerRenderer = false; export const enableSelectiveHydration = false; -export const enableLazyElements = false; export const enableCache = false; export const enableCacheElement = false; export const disableJavaScriptURLs = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 4283aa16e1201..1aeb14817ad70 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false; export const enableUpdaterTracking = false; export const enableSuspenseServerRenderer = false; export const enableSelectiveHydration = false; -export const enableLazyElements = false; export const enableCache = __EXPERIMENTAL__; export const enableCacheElement = __EXPERIMENTAL__; export const disableJavaScriptURLs = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js index 938b4d136d73d..9c19dc2a47c20 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js @@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false; export const enableUpdaterTracking = false; export const enableSuspenseServerRenderer = false; export const enableSelectiveHydration = false; -export const enableLazyElements = false; export const enableCache = true; export const enableCacheElement = true; export const disableJavaScriptURLs = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 7ad5cc56d9d92..75e1df4dc34b3 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false; export const enableUpdaterTracking = false; export const enableSuspenseServerRenderer = false; export const enableSelectiveHydration = false; -export const enableLazyElements = false; export const enableCache = true; export const enableCacheElement = true; export const enableSchedulerDebugging = false; diff --git a/packages/shared/forks/ReactFeatureFlags.testing.js b/packages/shared/forks/ReactFeatureFlags.testing.js index 0f65c001e5402..262e67017da19 100644 --- a/packages/shared/forks/ReactFeatureFlags.testing.js +++ b/packages/shared/forks/ReactFeatureFlags.testing.js @@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false; export const enableUpdaterTracking = false; export const enableSuspenseServerRenderer = false; export const enableSelectiveHydration = false; -export const enableLazyElements = false; export const enableCache = __EXPERIMENTAL__; export const enableCacheElement = __EXPERIMENTAL__; export const disableJavaScriptURLs = false; diff --git a/packages/shared/forks/ReactFeatureFlags.testing.www.js b/packages/shared/forks/ReactFeatureFlags.testing.www.js index 93d9860413db8..ed97f8e51ebc4 100644 --- a/packages/shared/forks/ReactFeatureFlags.testing.www.js +++ b/packages/shared/forks/ReactFeatureFlags.testing.www.js @@ -22,7 +22,6 @@ export const enableProfilerNestedUpdateScheduledHook = false; export const enableUpdaterTracking = false; export const enableSuspenseServerRenderer = true; export const enableSelectiveHydration = true; -export const enableLazyElements = false; export const enableCache = true; export const enableCacheElement = true; export const disableJavaScriptURLs = true; diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index a108f7a144b9e..5c64417f0bacf 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -70,7 +70,6 @@ export const enableGetInspectorDataForInstanceInProduction = false; export const enableSuspenseServerRenderer = true; export const enableSelectiveHydration = true; -export const enableLazyElements = true; export const enableCache = true; export const enableCacheElement = true;