Skip to content

Commit

Permalink
Ensure updates are applied when diffInCommitPhase is on (#26977)
Browse files Browse the repository at this point in the history
When we diffInCommitPhase there's no updatePayload, which caused no
update to be applied.

This is unfortunate because it would've been a lot easier to see this
oversight if we didn't have to support both flags.

I also carified 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.

DiffTrain build for [d1c8cda](d1c8cda)
  • Loading branch information
sebmarkbage committed Jun 20, 2023
1 parent 063f0e3 commit 4a74dd5
Show file tree
Hide file tree
Showing 15 changed files with 1,279 additions and 1,149 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
613e6f5fca3a7a63d115988d6312beb84d37b4db
d1c8cdae3b20a670ee91b684e8e0ad0c400ae51c
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-modern-58022814";
var ReactVersion = "18.3.0-www-modern-20bf6d53";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-modern-cbc1fa2b";
var ReactVersion = "18.3.0-www-modern-b9ce8919";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactART-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -9858,7 +9858,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "18.3.0-www-modern-12c03e2f",
version: "18.3.0-www-modern-a3ef0062",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1298 = {
Expand Down Expand Up @@ -9889,7 +9889,7 @@ var internals$jscomp$inline_1298 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-12c03e2f"
reconcilerVersion: "18.3.0-www-modern-a3ef0062"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1299 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
35 changes: 27 additions & 8 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23859,11 +23859,18 @@ function completeWork(current, workInProgress, renderLanes) {
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); // This must come at the very end of the complete phase.
// We may have props to update on the Hoistable instance.
if (diffInCommitPhase && supportsMutation) {
var 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);
} // This must come at the very end of the complete phase.

bubbleProperties(workInProgress);
preloadInstanceAndSuspendIfNeeded(workInProgress);
Expand All @@ -23880,7 +23887,15 @@ function completeWork(current, workInProgress, renderLanes) {
var _type = workInProgress.type;

if (current !== null && workInProgress.stateNode != null) {
updateHostComponent(current, workInProgress, _type, newProps);
if (diffInCommitPhase && supportsMutation) {
var _oldProps2 = current.memoizedProps;

if (_oldProps2 !== newProps) {
markUpdate(workInProgress);
}
} else {
updateHostComponent(current, workInProgress, _type, newProps);
}

if (current.ref !== workInProgress.ref) {
markRef(workInProgress);
Expand Down Expand Up @@ -27366,7 +27381,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) {
var updatePayload = finishedWork.updateQueue;
finishedWork.updateQueue = null;

if (updatePayload !== null) {
if (updatePayload !== null || diffInCommitPhase) {
try {
commitUpdate(
finishedWork.stateNode,
Expand Down Expand Up @@ -34179,7 +34194,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-classic-7c2add62";
var ReactVersion = "18.3.0-www-classic-ee7ec006";

function createPortal$1(
children,
Expand Down Expand Up @@ -42590,6 +42605,10 @@ function handleErrorInNextTick(error) {
throw error;
});
} // -------------------
// Mutation
// -------------------

var supportsMutation = true;
function commitMount(domElement, type, newProps, internalInstanceHandle) {
// Despite the naming that might imply otherwise, this method only
// fires if there is an `Update` effect scheduled during mounting.
Expand Down
35 changes: 27 additions & 8 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -23731,11 +23731,18 @@ function completeWork(current, workInProgress, renderLanes) {
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); // This must come at the very end of the complete phase.
// We may have props to update on the Hoistable instance.
if (diffInCommitPhase && supportsMutation) {
var 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);
} // This must come at the very end of the complete phase.

bubbleProperties(workInProgress);
preloadInstanceAndSuspendIfNeeded(workInProgress);
Expand All @@ -23752,7 +23759,15 @@ function completeWork(current, workInProgress, renderLanes) {
var _type = workInProgress.type;

if (current !== null && workInProgress.stateNode != null) {
updateHostComponent(current, workInProgress, _type, newProps);
if (diffInCommitPhase && supportsMutation) {
var _oldProps2 = current.memoizedProps;

if (_oldProps2 !== newProps) {
markUpdate(workInProgress);
}
} else {
updateHostComponent(current, workInProgress, _type, newProps);
}

if (current.ref !== workInProgress.ref) {
markRef(workInProgress);
Expand Down Expand Up @@ -27216,7 +27231,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) {
var updatePayload = finishedWork.updateQueue;
finishedWork.updateQueue = null;

if (updatePayload !== null) {
if (updatePayload !== null || diffInCommitPhase) {
try {
commitUpdate(
finishedWork.stateNode,
Expand Down Expand Up @@ -34024,7 +34039,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-modern-cbc1fa2b";
var ReactVersion = "18.3.0-www-modern-b9ce8919";

function createPortal$1(
children,
Expand Down Expand Up @@ -43100,6 +43115,10 @@ function handleErrorInNextTick(error) {
throw error;
});
} // -------------------
// Mutation
// -------------------

var supportsMutation = true;
function commitMount(domElement, type, newProps, internalInstanceHandle) {
// Despite the naming that might imply otherwise, this method only
// fires if there is an `Update` effect scheduled during mounting.
Expand Down
Loading

0 comments on commit 4a74dd5

Please sign in to comment.