Skip to content

Commit 1253920

Browse files
committed
[Fiber] Replay events between commits (facebook#33130)
Stacked on facebook#33129. Flagged behind `enableHydrationChangeEvent`. If you type into a controlled input before hydration and something else rerenders like a setState in an effect, then the controlled input will reset to whatever React thought it was. Even with event replaying that this is stacked on, if the second render happens before event replaying has fired in a separate task. We don't want to flush inside the commit phase because then things like flushSync in these events wouldn't work since they're inside the commit stack. This flushes all event replaying between renders by flushing it at the end of `flushSpawned` work. We've already committed at that point and is about to either do subsequent renders or yield to event loop for passive effects which could have these events fired anyway. This just ensures that they've already happened by the time subsequent renders fire. This means that there's now a type of event that fire between sync render passes. DiffTrain build for [54a5072](facebook@54a5072)
1 parent 52d9721 commit 1253920

34 files changed

+1242
-882
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
edf550b67936f2c62534ad5549bf580a4f581bd8
1+
54a50729cc47a884c2110d7c59dd5f850748e142
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
edf550b67936f2c62534ad5549bf580a4f581bd8
1+
54a50729cc47a884c2110d7c59dd5f850748e142

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ __DEV__ &&
15381538
exports.useTransition = function () {
15391539
return resolveDispatcher().useTransition();
15401540
};
1541-
exports.version = "19.2.0-www-classic-edf550b6-20250505";
1541+
exports.version = "19.2.0-www-classic-54a50729-20250506";
15421542
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15431543
"function" ===
15441544
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ __DEV__ &&
15381538
exports.useTransition = function () {
15391539
return resolveDispatcher().useTransition();
15401540
};
1541-
exports.version = "19.2.0-www-modern-edf550b6-20250505";
1541+
exports.version = "19.2.0-www-modern-54a50729-20250506";
15421542
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15431543
"function" ===
15441544
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,4 +636,4 @@ exports.useSyncExternalStore = function (
636636
exports.useTransition = function () {
637637
return ReactSharedInternals.H.useTransition();
638638
};
639-
exports.version = "19.2.0-www-classic-edf550b6-20250505";
639+
exports.version = "19.2.0-www-classic-54a50729-20250506";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,4 +636,4 @@ exports.useSyncExternalStore = function (
636636
exports.useTransition = function () {
637637
return ReactSharedInternals.H.useTransition();
638638
};
639-
exports.version = "19.2.0-www-modern-edf550b6-20250505";
639+
exports.version = "19.2.0-www-modern-54a50729-20250506";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ exports.useSyncExternalStore = function (
640640
exports.useTransition = function () {
641641
return ReactSharedInternals.H.useTransition();
642642
};
643-
exports.version = "19.2.0-www-classic-edf550b6-20250505";
643+
exports.version = "19.2.0-www-classic-54a50729-20250506";
644644
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
645645
"function" ===
646646
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ exports.useSyncExternalStore = function (
640640
exports.useTransition = function () {
641641
return ReactSharedInternals.H.useTransition();
642642
};
643-
exports.version = "19.2.0-www-modern-edf550b6-20250505";
643+
exports.version = "19.2.0-www-modern-54a50729-20250506";
644644
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
645645
"function" ===
646646
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11290,7 +11290,29 @@ __DEV__ &&
1129011290
case 26:
1129111291
case 5:
1129211292
recursivelyTraverseLayoutEffects(finishedRoot, finishedWork);
11293-
null === current && flags & 4 && commitHostMount(finishedWork);
11293+
if (null === current)
11294+
if (flags & 4) commitHostMount(finishedWork);
11295+
else if (flags & 64) {
11296+
finishedRoot = finishedWork.type;
11297+
current = finishedWork.memoizedProps;
11298+
prevProps = finishedWork.stateNode;
11299+
try {
11300+
runWithFiberInDEV(
11301+
finishedWork,
11302+
commitHydratedInstance,
11303+
prevProps,
11304+
finishedRoot,
11305+
current,
11306+
finishedWork
11307+
);
11308+
} catch (error) {
11309+
captureCommitPhaseError(
11310+
finishedWork,
11311+
finishedWork.return,
11312+
error
11313+
);
11314+
}
11315+
}
1129411316
flags & 512 && safelyAttachRef(finishedWork, finishedWork.return);
1129511317
break;
1129611318
case 12:
@@ -16919,6 +16941,7 @@ __DEV__ &&
1691916941
isSuspenseInstanceFallback = shim$2,
1692016942
getSuspenseInstanceFallbackErrorDetails = shim$2,
1692116943
registerSuspenseInstanceRetry = shim$2,
16944+
commitHydratedInstance = shim$2,
1692216945
clearSuspenseBoundary = shim$2,
1692316946
clearSuspenseBoundaryFromContainer = shim$2,
1692416947
hideDehydratedBoundary = shim$2,
@@ -19014,10 +19037,10 @@ __DEV__ &&
1901419037
(function () {
1901519038
var internals = {
1901619039
bundleType: 1,
19017-
version: "19.2.0-www-classic-edf550b6-20250505",
19040+
version: "19.2.0-www-classic-54a50729-20250506",
1901819041
rendererPackageName: "react-art",
1901919042
currentDispatcherRef: ReactSharedInternals,
19020-
reconcilerVersion: "19.2.0-www-classic-edf550b6-20250505"
19043+
reconcilerVersion: "19.2.0-www-classic-54a50729-20250506"
1902119044
};
1902219045
internals.overrideHookState = overrideHookState;
1902319046
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19051,7 +19074,7 @@ __DEV__ &&
1905119074
exports.Shape = Shape;
1905219075
exports.Surface = Surface;
1905319076
exports.Text = Text;
19054-
exports.version = "19.2.0-www-classic-edf550b6-20250505";
19077+
exports.version = "19.2.0-www-classic-54a50729-20250506";
1905519078
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1905619079
"function" ===
1905719080
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11108,7 +11108,29 @@ __DEV__ &&
1110811108
case 26:
1110911109
case 5:
1111011110
recursivelyTraverseLayoutEffects(finishedRoot, finishedWork);
11111-
null === current && flags & 4 && commitHostMount(finishedWork);
11111+
if (null === current)
11112+
if (flags & 4) commitHostMount(finishedWork);
11113+
else if (flags & 64) {
11114+
finishedRoot = finishedWork.type;
11115+
current = finishedWork.memoizedProps;
11116+
prevProps = finishedWork.stateNode;
11117+
try {
11118+
runWithFiberInDEV(
11119+
finishedWork,
11120+
commitHydratedInstance,
11121+
prevProps,
11122+
finishedRoot,
11123+
current,
11124+
finishedWork
11125+
);
11126+
} catch (error) {
11127+
captureCommitPhaseError(
11128+
finishedWork,
11129+
finishedWork.return,
11130+
error
11131+
);
11132+
}
11133+
}
1111211134
flags & 512 && safelyAttachRef(finishedWork, finishedWork.return);
1111311135
break;
1111411136
case 12:
@@ -16696,6 +16718,7 @@ __DEV__ &&
1669616718
isSuspenseInstanceFallback = shim$2,
1669716719
getSuspenseInstanceFallbackErrorDetails = shim$2,
1669816720
registerSuspenseInstanceRetry = shim$2,
16721+
commitHydratedInstance = shim$2,
1669916722
clearSuspenseBoundary = shim$2,
1670016723
clearSuspenseBoundaryFromContainer = shim$2,
1670116724
hideDehydratedBoundary = shim$2,
@@ -18786,10 +18809,10 @@ __DEV__ &&
1878618809
(function () {
1878718810
var internals = {
1878818811
bundleType: 1,
18789-
version: "19.2.0-www-modern-edf550b6-20250505",
18812+
version: "19.2.0-www-modern-54a50729-20250506",
1879018813
rendererPackageName: "react-art",
1879118814
currentDispatcherRef: ReactSharedInternals,
18792-
reconcilerVersion: "19.2.0-www-modern-edf550b6-20250505"
18815+
reconcilerVersion: "19.2.0-www-modern-54a50729-20250506"
1879318816
};
1879418817
internals.overrideHookState = overrideHookState;
1879518818
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -18823,7 +18846,7 @@ __DEV__ &&
1882318846
exports.Shape = Shape;
1882418847
exports.Surface = Surface;
1882518848
exports.Text = Text;
18826-
exports.version = "19.2.0-www-modern-edf550b6-20250505";
18849+
exports.version = "19.2.0-www-modern-54a50729-20250506";
1882718850
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1882818851
"function" ===
1882918852
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)