mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
act: Move didScheduleLegacyUpdate to ensureRootIsScheduled (#26552)
`act` uses the `didScheduleLegacyUpdate` field to simulate the behavior
of batching in React <17 and below. It's a quirk leftover from a
previous implementation, not intentionally designed.
This sets `didScheduleLegacyUpdate` every time a legacy root receives an
update as opposed to only when the `executionContext` is empty. There's
no real reason to do it this way over some other way except that it's
how it used to work before #26512 and we should try our best to maintain
the existing behavior, quirks and all, since existing tests may have
come to accidentally rely on it.
This should fix some (though not all) of the internal Meta tests that
started failing after #26512 landed.
Will add a regression test before merging.
DiffTrain build for [fec97ecbc4](https://github.com/facebook/react/commit/fec97ecbc4bc2e0e1407160289a8f5fac5241cbc)
This commit is contained in:
@@ -1 +1 @@
|
||||
9a9da7721e5b73a8af242807e463e2af842c58ee
|
||||
fec97ecbc4bc2e0e1407160289a8f5fac5241cbc
|
||||
|
||||
@@ -27,7 +27,7 @@ if (
|
||||
}
|
||||
"use strict";
|
||||
|
||||
var ReactVersion = "18.3.0-www-modern-bfaf8fe7";
|
||||
var ReactVersion = "18.3.0-www-modern-0ed50ada";
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
|
||||
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
|
||||
return self;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-www-classic-4f49fe42";
|
||||
var ReactVersion = "18.3.0-www-classic-b7529c47";
|
||||
|
||||
var LegacyRoot = 0;
|
||||
var ConcurrentRoot = 1;
|
||||
@@ -23173,6 +23173,11 @@ function ensureRootIsScheduled(root) {
|
||||
// unblock additional features we have planned.
|
||||
scheduleTaskForRootDuringMicrotask(root, now$1());
|
||||
}
|
||||
|
||||
if (ReactCurrentActQueue$1.isBatchingLegacy && root.tag === LegacyRoot) {
|
||||
// Special `act` case: Record whenever a legacy update is scheduled.
|
||||
ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
|
||||
}
|
||||
}
|
||||
function flushSyncWorkOnAllRoots() {
|
||||
// This is allowed to be called synchronously, but the caller should check
|
||||
@@ -23980,10 +23985,8 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) {
|
||||
executionContext === NoContext &&
|
||||
(fiber.mode & ConcurrentMode) === NoMode
|
||||
) {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy) {
|
||||
// Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
|
||||
ReactCurrentActQueue.didScheduleLegacyUpdate = true;
|
||||
} else {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy);
|
||||
else {
|
||||
// Flush the synchronous work now, unless we're already working or inside
|
||||
// a batch. This is intentionally inside scheduleUpdateOnFiber instead of
|
||||
// scheduleCallbackForFiber to preserve the ability to schedule a callback
|
||||
|
||||
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
|
||||
return self;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-www-modern-c67d4626";
|
||||
var ReactVersion = "18.3.0-www-modern-71e9d049";
|
||||
|
||||
var LegacyRoot = 0;
|
||||
var ConcurrentRoot = 1;
|
||||
@@ -22838,6 +22838,11 @@ function ensureRootIsScheduled(root) {
|
||||
// unblock additional features we have planned.
|
||||
scheduleTaskForRootDuringMicrotask(root, now$1());
|
||||
}
|
||||
|
||||
if (ReactCurrentActQueue$1.isBatchingLegacy && root.tag === LegacyRoot) {
|
||||
// Special `act` case: Record whenever a legacy update is scheduled.
|
||||
ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
|
||||
}
|
||||
}
|
||||
function flushSyncWorkOnAllRoots() {
|
||||
// This is allowed to be called synchronously, but the caller should check
|
||||
@@ -23645,10 +23650,8 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) {
|
||||
executionContext === NoContext &&
|
||||
(fiber.mode & ConcurrentMode) === NoMode
|
||||
) {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy) {
|
||||
// Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
|
||||
ReactCurrentActQueue.didScheduleLegacyUpdate = true;
|
||||
} else {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy);
|
||||
else {
|
||||
// Flush the synchronous work now, unless we're already working or inside
|
||||
// a batch. This is intentionally inside scheduleUpdateOnFiber instead of
|
||||
// scheduleCallbackForFiber to preserve the ability to schedule a callback
|
||||
|
||||
@@ -9737,7 +9737,7 @@ var slice = Array.prototype.slice,
|
||||
return null;
|
||||
},
|
||||
bundleType: 0,
|
||||
version: "18.3.0-www-modern-3b22d407",
|
||||
version: "18.3.0-www-modern-77b45d24",
|
||||
rendererPackageName: "react-art"
|
||||
};
|
||||
var internals$jscomp$inline_1324 = {
|
||||
@@ -9768,7 +9768,7 @@ var internals$jscomp$inline_1324 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-www-modern-3b22d407"
|
||||
reconcilerVersion: "18.3.0-www-modern-77b45d24"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_1325 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
|
||||
@@ -28134,6 +28134,11 @@ function ensureRootIsScheduled(root) {
|
||||
// unblock additional features we have planned.
|
||||
scheduleTaskForRootDuringMicrotask(root, now$1());
|
||||
}
|
||||
|
||||
if (ReactCurrentActQueue$1.isBatchingLegacy && root.tag === LegacyRoot) {
|
||||
// Special `act` case: Record whenever a legacy update is scheduled.
|
||||
ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
|
||||
}
|
||||
}
|
||||
function flushSyncWorkOnAllRoots() {
|
||||
// This is allowed to be called synchronously, but the caller should check
|
||||
@@ -28959,10 +28964,8 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) {
|
||||
executionContext === NoContext &&
|
||||
(fiber.mode & ConcurrentMode) === NoMode
|
||||
) {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy) {
|
||||
// Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
|
||||
ReactCurrentActQueue.didScheduleLegacyUpdate = true;
|
||||
} else {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy);
|
||||
else {
|
||||
// Flush the synchronous work now, unless we're already working or inside
|
||||
// a batch. This is intentionally inside scheduleUpdateOnFiber instead of
|
||||
// scheduleCallbackForFiber to preserve the ability to schedule a callback
|
||||
@@ -33348,7 +33351,7 @@ function createFiberRoot(
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-www-classic-1bf554dd";
|
||||
var ReactVersion = "18.3.0-www-classic-27be8f4e";
|
||||
|
||||
function createPortal$1(
|
||||
children,
|
||||
|
||||
@@ -27975,6 +27975,11 @@ function ensureRootIsScheduled(root) {
|
||||
// unblock additional features we have planned.
|
||||
scheduleTaskForRootDuringMicrotask(root, now$1());
|
||||
}
|
||||
|
||||
if (ReactCurrentActQueue$1.isBatchingLegacy && root.tag === LegacyRoot) {
|
||||
// Special `act` case: Record whenever a legacy update is scheduled.
|
||||
ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
|
||||
}
|
||||
}
|
||||
function flushSyncWorkOnAllRoots() {
|
||||
// This is allowed to be called synchronously, but the caller should check
|
||||
@@ -28800,10 +28805,8 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) {
|
||||
executionContext === NoContext &&
|
||||
(fiber.mode & ConcurrentMode) === NoMode
|
||||
) {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy) {
|
||||
// Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
|
||||
ReactCurrentActQueue.didScheduleLegacyUpdate = true;
|
||||
} else {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy);
|
||||
else {
|
||||
// Flush the synchronous work now, unless we're already working or inside
|
||||
// a batch. This is intentionally inside scheduleUpdateOnFiber instead of
|
||||
// scheduleCallbackForFiber to preserve the ability to schedule a callback
|
||||
@@ -33184,7 +33187,7 @@ function createFiberRoot(
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-www-modern-3b22d407";
|
||||
var ReactVersion = "18.3.0-www-modern-77b45d24";
|
||||
|
||||
function createPortal$1(
|
||||
children,
|
||||
|
||||
@@ -31325,6 +31325,11 @@ function ensureRootIsScheduled(root) {
|
||||
// unblock additional features we have planned.
|
||||
scheduleTaskForRootDuringMicrotask(root, now$1());
|
||||
}
|
||||
|
||||
if (ReactCurrentActQueue$1.isBatchingLegacy && root.tag === LegacyRoot) {
|
||||
// Special `act` case: Record whenever a legacy update is scheduled.
|
||||
ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
|
||||
}
|
||||
}
|
||||
function flushSyncWorkOnAllRoots() {
|
||||
// This is allowed to be called synchronously, but the caller should check
|
||||
@@ -32150,10 +32155,8 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) {
|
||||
executionContext === NoContext &&
|
||||
(fiber.mode & ConcurrentMode) === NoMode
|
||||
) {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy) {
|
||||
// Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
|
||||
ReactCurrentActQueue.didScheduleLegacyUpdate = true;
|
||||
} else {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy);
|
||||
else {
|
||||
// Flush the synchronous work now, unless we're already working or inside
|
||||
// a batch. This is intentionally inside scheduleUpdateOnFiber instead of
|
||||
// scheduleCallbackForFiber to preserve the ability to schedule a callback
|
||||
@@ -36539,7 +36542,7 @@ function createFiberRoot(
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-www-classic-49934517";
|
||||
var ReactVersion = "18.3.0-www-classic-ca64d104";
|
||||
|
||||
function createPortal$1(
|
||||
children,
|
||||
|
||||
@@ -28594,6 +28594,11 @@ function ensureRootIsScheduled(root) {
|
||||
// unblock additional features we have planned.
|
||||
scheduleTaskForRootDuringMicrotask(root, now$1());
|
||||
}
|
||||
|
||||
if (ReactCurrentActQueue$1.isBatchingLegacy && root.tag === LegacyRoot) {
|
||||
// Special `act` case: Record whenever a legacy update is scheduled.
|
||||
ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
|
||||
}
|
||||
}
|
||||
function flushSyncWorkOnAllRoots() {
|
||||
// This is allowed to be called synchronously, but the caller should check
|
||||
@@ -29419,10 +29424,8 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) {
|
||||
executionContext === NoContext &&
|
||||
(fiber.mode & ConcurrentMode) === NoMode
|
||||
) {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy) {
|
||||
// Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
|
||||
ReactCurrentActQueue.didScheduleLegacyUpdate = true;
|
||||
} else {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy);
|
||||
else {
|
||||
// Flush the synchronous work now, unless we're already working or inside
|
||||
// a batch. This is intentionally inside scheduleUpdateOnFiber instead of
|
||||
// scheduleCallbackForFiber to preserve the ability to schedule a callback
|
||||
@@ -33803,7 +33806,7 @@ function createFiberRoot(
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-www-modern-845598d4";
|
||||
var ReactVersion = "18.3.0-www-modern-835f126b";
|
||||
|
||||
function createPortal$1(
|
||||
children,
|
||||
|
||||
@@ -14773,7 +14773,7 @@ Internals.Events = [
|
||||
var devToolsConfig$jscomp$inline_1769 = {
|
||||
findFiberByHostInstance: getClosestInstanceFromNode,
|
||||
bundleType: 0,
|
||||
version: "18.3.0-www-classic-4f49fe42",
|
||||
version: "18.3.0-www-classic-b7529c47",
|
||||
rendererPackageName: "react-dom"
|
||||
};
|
||||
var internals$jscomp$inline_2211 = {
|
||||
@@ -14803,7 +14803,7 @@ var internals$jscomp$inline_2211 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-www-classic-4f49fe42"
|
||||
reconcilerVersion: "18.3.0-www-classic-b7529c47"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_2212 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
@@ -16805,4 +16805,4 @@ exports.unstable_renderSubtreeIntoContainer = function (
|
||||
);
|
||||
};
|
||||
exports.unstable_runWithPriority = runWithPriority;
|
||||
exports.version = "18.3.0-www-classic-4f49fe42";
|
||||
exports.version = "18.3.0-www-classic-b7529c47";
|
||||
|
||||
@@ -15966,7 +15966,7 @@ Internals.Events = [
|
||||
var devToolsConfig$jscomp$inline_1799 = {
|
||||
findFiberByHostInstance: getClosestInstanceFromNode,
|
||||
bundleType: 0,
|
||||
version: "18.3.0-www-modern-bfaf8fe7",
|
||||
version: "18.3.0-www-modern-0ed50ada",
|
||||
rendererPackageName: "react-dom"
|
||||
};
|
||||
var internals$jscomp$inline_2178 = {
|
||||
@@ -15997,7 +15997,7 @@ var internals$jscomp$inline_2178 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-www-modern-bfaf8fe7"
|
||||
reconcilerVersion: "18.3.0-www-modern-0ed50ada"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_2179 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
@@ -16317,4 +16317,4 @@ exports.unstable_createEventHandle = function (type, options) {
|
||||
return eventHandle;
|
||||
};
|
||||
exports.unstable_runWithPriority = runWithPriority;
|
||||
exports.version = "18.3.0-www-modern-bfaf8fe7";
|
||||
exports.version = "18.3.0-www-modern-0ed50ada";
|
||||
|
||||
@@ -20063,6 +20063,11 @@ function ensureRootIsScheduled(root) {
|
||||
scheduleImmediateTask(processRootScheduleInMicrotask);
|
||||
}
|
||||
}
|
||||
|
||||
if (ReactCurrentActQueue$1.isBatchingLegacy && root.tag === LegacyRoot) {
|
||||
// Special `act` case: Record whenever a legacy update is scheduled.
|
||||
ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
|
||||
}
|
||||
}
|
||||
function flushSyncWorkOnAllRoots() {
|
||||
// This is allowed to be called synchronously, but the caller should check
|
||||
@@ -20673,10 +20678,8 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) {
|
||||
executionContext === NoContext &&
|
||||
(fiber.mode & ConcurrentMode) === NoMode
|
||||
) {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy) {
|
||||
// Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
|
||||
ReactCurrentActQueue.didScheduleLegacyUpdate = true;
|
||||
} else {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy);
|
||||
else {
|
||||
// Flush the synchronous work now, unless we're already working or inside
|
||||
// a batch. This is intentionally inside scheduleUpdateOnFiber instead of
|
||||
// scheduleCallbackForFiber to preserve the ability to schedule a callback
|
||||
@@ -24498,7 +24501,7 @@ function createFiberRoot(
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-www-classic-4acb9da4";
|
||||
var ReactVersion = "18.3.0-www-classic-ce15662b";
|
||||
|
||||
// Might add PROFILE later.
|
||||
|
||||
|
||||
@@ -20063,6 +20063,11 @@ function ensureRootIsScheduled(root) {
|
||||
scheduleImmediateTask(processRootScheduleInMicrotask);
|
||||
}
|
||||
}
|
||||
|
||||
if (ReactCurrentActQueue$1.isBatchingLegacy && root.tag === LegacyRoot) {
|
||||
// Special `act` case: Record whenever a legacy update is scheduled.
|
||||
ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
|
||||
}
|
||||
}
|
||||
function flushSyncWorkOnAllRoots() {
|
||||
// This is allowed to be called synchronously, but the caller should check
|
||||
@@ -20673,10 +20678,8 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) {
|
||||
executionContext === NoContext &&
|
||||
(fiber.mode & ConcurrentMode) === NoMode
|
||||
) {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy) {
|
||||
// Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
|
||||
ReactCurrentActQueue.didScheduleLegacyUpdate = true;
|
||||
} else {
|
||||
if (ReactCurrentActQueue.isBatchingLegacy);
|
||||
else {
|
||||
// Flush the synchronous work now, unless we're already working or inside
|
||||
// a batch. This is intentionally inside scheduleUpdateOnFiber instead of
|
||||
// scheduleCallbackForFiber to preserve the ability to schedule a callback
|
||||
@@ -24498,7 +24501,7 @@ function createFiberRoot(
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-www-modern-bfaf8fe7";
|
||||
var ReactVersion = "18.3.0-www-modern-0ed50ada";
|
||||
|
||||
// Might add PROFILE later.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user