Skip to content

Commit b66ae09

Browse files
committed
Track subtreeFlags et al with bubbleProperties
Original PR: #19836
1 parent de75315 commit b66ae09

8 files changed

+458
-178
lines changed

Diff for: packages/react-reconciler/src/ReactFiber.new.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
enableFundamentalAPI,
2929
enableScopeAPI,
3030
} from 'shared/ReactFeatureFlags';
31-
import {NoFlags, Placement} from './ReactFiberFlags';
31+
import {NoFlags, Placement, StaticMask} from './ReactFiberFlags';
3232
import {ConcurrentRoot, BlockingRoot} from './ReactRootTags';
3333
import {
3434
IndeterminateComponent,
@@ -299,6 +299,9 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
299299
}
300300
}
301301

302+
// Reset all effects except static ones.
303+
// Static effects are not specific to a render.
304+
workInProgress.flags = current.flags & StaticMask;
302305
workInProgress.childLanes = current.childLanes;
303306
workInProgress.lanes = current.lanes;
304307

Diff for: packages/react-reconciler/src/ReactFiber.old.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
enableFundamentalAPI,
2929
enableScopeAPI,
3030
} from 'shared/ReactFeatureFlags';
31-
import {NoFlags, Placement} from './ReactFiberFlags';
31+
import {NoFlags, Placement, StaticMask} from './ReactFiberFlags';
3232
import {ConcurrentRoot, BlockingRoot} from './ReactRootTags';
3333
import {
3434
IndeterminateComponent,
@@ -299,6 +299,9 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
299299
}
300300
}
301301

302+
// Reset all effects except static ones.
303+
// Static effects are not specific to a render.
304+
workInProgress.flags = current.flags & StaticMask;
302305
workInProgress.childLanes = current.childLanes;
303306
workInProgress.lanes = current.lanes;
304307

Diff for: packages/react-reconciler/src/ReactFiberBeginWork.new.js

+7
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import {
6363
Deletion,
6464
ChildDeletion,
6565
ForceUpdateForLegacySuspense,
66+
StaticMask,
6667
} from './ReactFiberFlags';
6768
import ReactSharedInternals from 'shared/ReactSharedInternals';
6869
import {
@@ -2092,6 +2093,12 @@ function updateSuspenseFallbackChildren(
20922093
currentPrimaryChildFragment,
20932094
primaryChildProps,
20942095
);
2096+
2097+
// Since we're reusing a current tree, we need to reuse the flags, too.
2098+
// (We don't do this in legacy mode, because in legacy mode we don't re-use
2099+
// the current tree; see previous branch.)
2100+
primaryChildFragment.subtreeFlags =
2101+
currentPrimaryChildFragment.subtreeFlags & StaticMask;
20952102
}
20962103
let fallbackChildFragment;
20972104
if (currentFallbackChildFragment !== null) {

Diff for: packages/react-reconciler/src/ReactFiberBeginWork.old.js

+7
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import {
6363
Deletion,
6464
ChildDeletion,
6565
ForceUpdateForLegacySuspense,
66+
StaticMask,
6667
} from './ReactFiberFlags';
6768
import ReactSharedInternals from 'shared/ReactSharedInternals';
6869
import {
@@ -2092,6 +2093,12 @@ function updateSuspenseFallbackChildren(
20922093
currentPrimaryChildFragment,
20932094
primaryChildProps,
20942095
);
2096+
2097+
// Since we're reusing a current tree, we need to reuse the flags, too.
2098+
// (We don't do this in legacy mode, because in legacy mode we don't re-use
2099+
// the current tree; see previous branch.)
2100+
primaryChildFragment.subtreeFlags =
2101+
currentPrimaryChildFragment.subtreeFlags & StaticMask;
20952102
}
20962103
let fallbackChildFragment;
20972104
if (currentFallbackChildFragment !== null) {

0 commit comments

Comments
 (0)