Skip to content

Commit b8a8b0a

Browse files
committed
Clarify that updateHostComponent is unnecessary in the new flag
We reuse updateHostComponent for HostSingleton and HostHoistables since it has a somewhat complex path but that means you have to remember when editing updateHostComponent that it's not just used for that tag. Luckily with the new flag, this is actually unnecessary since we just need to mark it for update if any props have changed and then we diff it later.
1 parent a108580 commit b8a8b0a

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

packages/react-reconciler/src/ReactFiberCompleteWork.js

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,17 +1160,23 @@ function completeWork(
11601160
return null;
11611161
} else {
11621162
// This is a Hoistable Instance
1163-
//
1164-
// We may have props to update on the Hoistable instance. We use the
1165-
// updateHostComponent path becuase it produces the update queue
1166-
// we need for Hoistables.
1167-
updateHostComponent(
1168-
current,
1169-
workInProgress,
1170-
type,
1171-
newProps,
1172-
renderLanes,
1173-
);
1163+
// We may have props to update on the Hoistable instance.
1164+
if (diffInCommitPhase && supportsMutation) {
1165+
const oldProps = current.memoizedProps;
1166+
if (oldProps !== newProps) {
1167+
markUpdate(workInProgress);
1168+
}
1169+
} else {
1170+
// We use the updateHostComponent path becuase it produces
1171+
// the update queue we need for Hoistables.
1172+
updateHostComponent(
1173+
current,
1174+
workInProgress,
1175+
type,
1176+
newProps,
1177+
renderLanes,
1178+
);
1179+
}
11741180

11751181
// This must come at the very end of the complete phase.
11761182
bubbleProperties(workInProgress);
@@ -1192,13 +1198,20 @@ function completeWork(
11921198
const rootContainerInstance = getRootHostContainer();
11931199
const type = workInProgress.type;
11941200
if (current !== null && workInProgress.stateNode != null) {
1195-
updateHostComponent(
1196-
current,
1197-
workInProgress,
1198-
type,
1199-
newProps,
1200-
renderLanes,
1201-
);
1201+
if (diffInCommitPhase && supportsMutation) {
1202+
const oldProps = current.memoizedProps;
1203+
if (oldProps !== newProps) {
1204+
markUpdate(workInProgress);
1205+
}
1206+
} else {
1207+
updateHostComponent(
1208+
current,
1209+
workInProgress,
1210+
type,
1211+
newProps,
1212+
renderLanes,
1213+
);
1214+
}
12021215

12031216
if (current.ref !== workInProgress.ref) {
12041217
markRef(workInProgress);

0 commit comments

Comments
 (0)