Skip to content

Commit

Permalink
Land enableLazyElements flag (#24407)
Browse files Browse the repository at this point in the history
This flag is already enabled on all relevant surfaces. We can remove it.
  • Loading branch information
acdlite authored Apr 20, 2022
1 parent 4175f05 commit 1e748b4
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 118 deletions.
79 changes: 31 additions & 48 deletions packages/react-reconciler/src/ReactChildFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)) {
Expand Down
79 changes: 31 additions & 48 deletions packages/react-reconciler/src/ReactChildFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
15 changes: 6 additions & 9 deletions packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ import {
disableModulePatternComponents,
warnAboutDefaultPropsOnFunctionComponents,
enableScopeAPI,
enableLazyElements,
enableSuspenseAvoidThisFallbackFizz,
} from 'shared/ReactFeatureFlags';

Expand Down Expand Up @@ -1162,14 +1161,12 @@ function renderNodeDestructive(
);
// eslint-disable-next-line-no-fallthrough
case REACT_LAZY_TYPE: {
if (enableLazyElements) {
const lazyNode: LazyComponentType<any, any> = (node: any);
const payload = lazyNode._payload;
const init = lazyNode._init;
const resolvedNode = init(payload);
renderNodeDestructive(request, task, resolvedNode);
return;
}
const lazyNode: LazyComponentType<any, any> = (node: any);
const payload = lazyNode._payload;
const init = lazyNode._init;
const resolvedNode = init(payload);
renderNodeDestructive(request, task, resolvedNode);
return;
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.testing.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 1e748b4

Please sign in to comment.