Skip to content

Commit

Permalink
Clarify that updateHostComponent is unnecessary in the new flag
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebmarkbage committed Jun 20, 2023
1 parent a108580 commit b8a8b0a
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions packages/react-reconciler/src/ReactFiberCompleteWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -1160,17 +1160,23 @@ function completeWork(
return null;
} else {
// This is a Hoistable Instance
//
// We may have props to update on the Hoistable instance. We use the
// updateHostComponent path becuase it produces the update queue
// we need for Hoistables.
updateHostComponent(
current,
workInProgress,
type,
newProps,
renderLanes,
);
// We may have props to update on the Hoistable instance.
if (diffInCommitPhase && supportsMutation) {
const oldProps = current.memoizedProps;
if (oldProps !== newProps) {
markUpdate(workInProgress);
}
} else {
// We use the updateHostComponent path becuase it produces
// the update queue we need for Hoistables.
updateHostComponent(
current,
workInProgress,
type,
newProps,
renderLanes,
);
}

// This must come at the very end of the complete phase.
bubbleProperties(workInProgress);
Expand All @@ -1192,13 +1198,20 @@ function completeWork(
const rootContainerInstance = getRootHostContainer();
const type = workInProgress.type;
if (current !== null && workInProgress.stateNode != null) {
updateHostComponent(
current,
workInProgress,
type,
newProps,
renderLanes,
);
if (diffInCommitPhase && supportsMutation) {
const oldProps = current.memoizedProps;
if (oldProps !== newProps) {
markUpdate(workInProgress);
}
} else {
updateHostComponent(
current,
workInProgress,
type,
newProps,
renderLanes,
);
}

if (current.ref !== workInProgress.ref) {
markRef(workInProgress);
Expand Down

0 comments on commit b8a8b0a

Please sign in to comment.