Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
enableComponentPerformanceTrack,
enableViewTransition,
enableFragmentRefs,
enableEagerAlternateStateNodeCleanup,
} from 'shared/ReactFeatureFlags';
import {
FunctionComponent,
Expand Down Expand Up @@ -2171,6 +2172,11 @@ function commitMutationEffectsOnFiber(
}
}
}
if (enableEagerAlternateStateNodeCleanup) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the else branch of if (supportsMutation) and it should check if (supportsPersistence) since this should only apply to the persistent mode which is the only mode that clones the state nodes.

The flag is only on in RN but it's still on for Paper unnecessarily. You're better off turning the flag on everywhere else because that flushes out any issues where it would have issues if it turned on in the other renders. Like not gating it properly on supportsPersistence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me do that. My thinking was that it is a no-op in supportsMutation mode as stateNode will be the same between finishedWork and alternate.

thanks for pointing out the supportsPersistence. I will also add a comment explaining why this is needed.

if (finishedWork.alternate !== null) {
finishedWork.alternate.stateNode = finishedWork.stateNode;
}
}
break;
}
case HostText: {
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ export const enablePersistedModeClonedFlag = false;

export const enableShallowPropDiffing = false;

export const enableEagerAlternateStateNodeCleanup = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be true here, as well as the other non-RN files. Since this only impacts RN, we don't need to set it to false. Makes it easier to roll out - and if it causes a test to fail somehow (it shouldn't) we'll catch it now instead of when trying to remove the flag


/**
* Enables an expiration time for retry lanes to avoid starvation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const enableObjectFiber = __VARIANT__;
export const enableHiddenSubtreeInsertionEffectCleanup = __VARIANT__;
export const enablePersistedModeClonedFlag = __VARIANT__;
export const enableShallowPropDiffing = __VARIANT__;
export const enableEagerAlternateStateNodeCleanup = __VARIANT__;
export const passChildrenWhenCloningPersistedNodes = __VARIANT__;
export const enableFastAddPropertiesInDiffing = __VARIANT__;
export const enableLazyPublicInstanceInFabric = __VARIANT__;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const {
enableObjectFiber,
enablePersistedModeClonedFlag,
enableShallowPropDiffing,
enableEagerAlternateStateNodeCleanup,
passChildrenWhenCloningPersistedNodes,
enableFastAddPropertiesInDiffing,
enableLazyPublicInstanceInFabric,
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const enableSchedulingProfiler = __PROFILE__;
export const enableComponentPerformanceTrack = false;
export const enableScopeAPI = false;
export const enableShallowPropDiffing = false;
export const enableEagerAlternateStateNodeCleanup = false;
export const enableSuspenseAvoidThisFallback = false;
export const enableSuspenseCallback = false;
export const enableTaint = true;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const enableInfiniteRenderLoopDetection = false;

export const renameElementSymbol = true;
export const enableShallowPropDiffing = false;
export const enableEagerAlternateStateNodeCleanup = false;

export const enableYieldingBeforePassive = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const enableSchedulingProfiler = __PROFILE__;
export const enableComponentPerformanceTrack = false;
export const enableScopeAPI = false;
export const enableShallowPropDiffing = false;
export const enableEagerAlternateStateNodeCleanup = false;
export const enableSuspenseAvoidThisFallback = false;
export const enableSuspenseCallback = false;
export const enableTaint = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const renameElementSymbol = false;

export const enableObjectFiber = false;
export const enableShallowPropDiffing = false;
export const enableEagerAlternateStateNodeCleanup = false;

export const enableHydrationLaneScheduling = true;

Expand Down
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export const disableLegacyMode = true;

export const enableShallowPropDiffing = false;

export const enableEagerAlternateStateNodeCleanup = false;

export const enableLazyPublicInstanceInFabric = false;

export const enableGestureTransition = false;
Expand Down
Loading