Skip to content

Commit

Permalink
Use the disableLegacyMode where ever we check the ConcurrentMode mode (
Browse files Browse the repository at this point in the history
…#28657)

Saves some bytes and ensures that we're actually disabling it.

Turns out this flag wasn't disabling React Native/Fabric, React Noop and
React ART legacy modes so those are updated too.

Should be rebased on #28681.

DiffTrain build for commit 5de8703.
  • Loading branch information
sebmarkbage committed Apr 3, 2024
1 parent 6d2deb7 commit aac8c4d
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<6acbb1692d59c6261eb71f7ca657935e>>
* @generated SignedSource<<2cc0c2d7fd5b0cce9600b3f7552b625c>>
*/

"use strict";
Expand Down Expand Up @@ -421,11 +421,15 @@ if (__DEV__) {

case TracingMarkerComponent:
return "TracingMarker";
// The display name for this tags come from the user-provided type:
// The display name for these tags come from the user-provided type:

case IncompleteClassComponent:
case IncompleteFunctionComponent:

// Fallthrough

case ClassComponent:
case FunctionComponent:
case IncompleteClassComponent:
case MemoComponent:
case SimpleMemoComponent:
if (typeof type === "function") {
Expand Down Expand Up @@ -4038,7 +4042,9 @@ if (__DEV__) {
function flushSyncWorkOnLegacyRootsOnly() {
// This is allowed to be called synchronously, but the caller should check
// the execution context first.
flushSyncWorkAcrossRoots_impl(true);
{
flushSyncWorkAcrossRoots_impl(true);
}
}

function flushSyncWorkAcrossRoots_impl(onlyLegacy) {
Expand Down Expand Up @@ -18073,10 +18079,11 @@ if (__DEV__) {
var newProps = workInProgress.pendingProps; // Note: This intentionally doesn't check if we're hydrating because comparing

switch (workInProgress.tag) {
case IncompleteFunctionComponent:

case LazyComponent:
case SimpleMemoComponent:
case FunctionComponent:
case IncompleteFunctionComponent:
case ForwardRef:
case Fragment:
case Mode:
Expand Down Expand Up @@ -18398,8 +18405,8 @@ if (__DEV__) {
return null;

case IncompleteClassComponent: {
// Same as class component case. I put it down here so that the tags are
// sequential to ensure this switch is compiled to a jump table.

var _Component = workInProgress.type;

if (isContextProvider(_Component)) {
Expand Down Expand Up @@ -22831,6 +22838,7 @@ if (__DEV__) {
if (
lane === SyncLane &&
executionContext === NoContext &&
!disableLegacyMode &&
(fiber.mode & ConcurrentMode) === NoMode
) {
if (ReactCurrentActQueue.isBatchingLegacy);
Expand Down Expand Up @@ -23391,6 +23399,7 @@ if (__DEV__) {
// next event, not at the end of the previous one.
if (
rootWithPendingPassiveEffects !== null &&
!disableLegacyMode &&
rootWithPendingPassiveEffects.tag === LegacyRoot &&
(executionContext & (RenderContext | CommitContext)) === NoContext
) {
Expand Down Expand Up @@ -26651,14 +26660,16 @@ if (__DEV__) {
}

{
switch (tag) {
case ConcurrentRoot:
this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()";
break;
{
switch (tag) {
case ConcurrentRoot:
this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()";
break;

case LegacyRoot:
this._debugRootType = hydrate ? "hydrate()" : "render()";
break;
case LegacyRoot:
this._debugRootType = hydrate ? "hydrate()" : "render()";
break;
}
}
}
}
Expand Down Expand Up @@ -26726,7 +26737,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-canary-220dd579";
var ReactVersion = "19.0.0-canary-26794664";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<69239f8b92157c4f6a4c39bc63f04216>>
* @generated SignedSource<<ecfcb176376bc197ec85ddd358a1c474>>
*/

"use strict";
Expand Down Expand Up @@ -155,9 +155,10 @@ function getComponentNameFromFiber(fiber) {
return "SuspenseList";
case 25:
return "TracingMarker";
case 17:
case 28:
case 1:
case 0:
case 17:
case 14:
case 15:
if ("function" === typeof type)
Expand Down Expand Up @@ -5571,10 +5572,10 @@ function bubbleProperties(completedWork) {
function completeWork(current, workInProgress, renderLanes) {
var newProps = workInProgress.pendingProps;
switch (workInProgress.tag) {
case 28:
case 16:
case 15:
case 0:
case 28:
case 11:
case 7:
case 8:
Expand Down Expand Up @@ -9190,7 +9191,7 @@ var devToolsConfig$jscomp$inline_990 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-canary-7c981d93",
version: "19.0.0-canary-e5758235",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1175 = {
Expand Down Expand Up @@ -9221,7 +9222,7 @@ var internals$jscomp$inline_1175 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-7c981d93"
reconcilerVersion: "19.0.0-canary-e5758235"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1176 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b3b698a77d1e2b886a5c5302efcce57c>>
* @generated SignedSource<<ac41f3084be71e7e00628cd7386a97f2>>
*/

"use strict";
Expand Down Expand Up @@ -155,9 +155,10 @@ function getComponentNameFromFiber(fiber) {
return "SuspenseList";
case 25:
return "TracingMarker";
case 17:
case 28:
case 1:
case 0:
case 17:
case 14:
case 15:
if ("function" === typeof type)
Expand Down Expand Up @@ -5802,10 +5803,10 @@ function bubbleProperties(completedWork) {
function completeWork(current, workInProgress, renderLanes) {
var newProps = workInProgress.pendingProps;
switch (workInProgress.tag) {
case 28:
case 16:
case 15:
case 0:
case 28:
case 11:
case 7:
case 8:
Expand Down Expand Up @@ -9806,7 +9807,7 @@ var devToolsConfig$jscomp$inline_1074 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-canary-0b841a65",
version: "19.0.0-canary-1b065d5e",
rendererPackageName: "react-test-renderer"
};
(function (internals) {
Expand Down Expand Up @@ -9850,7 +9851,7 @@ var devToolsConfig$jscomp$inline_1074 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-0b841a65"
reconcilerVersion: "19.0.0-canary-1b065d5e"
});
exports._Scheduler = Scheduler;
exports.act = act;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<81a3185ee1038a29c67be8ea0fa5da53>>
* @generated SignedSource<<ba923810748b6a7ee3587bd2f20b845d>>
*/

"use strict";
Expand All @@ -26,7 +26,7 @@ if (__DEV__) {
}
var dynamicFlagsUntyped = require("ReactNativeInternalFeatureFlags");

var ReactVersion = "19.0.0-canary-45dc54bd";
var ReactVersion = "19.0.0-canary-f7b8f960";

// ATTENTION
// When adding new symbols to this file,
Expand Down Expand Up @@ -508,6 +508,7 @@ if (__DEV__) {
// because JSX is an extremely hot path.

var enableRefAsProp = false;
var disableLegacyMode = false;

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down Expand Up @@ -3251,7 +3252,10 @@ if (__DEV__) {
// triggered during an async event, because this is how the legacy
// implementation of `act` behaved.

ReactCurrentActQueue.isBatchingLegacy = true;
{
ReactCurrentActQueue.isBatchingLegacy = true;
}

var result; // This tracks whether the `act` call is awaited. In certain cases, not
// awaiting it is a mistake, so we will detect that and warn.

Expand All @@ -3261,10 +3265,14 @@ if (__DEV__) {
// Reset this to `false` right before entering the React work loop. The
// only place we ever read this fields is just below, right after running
// the callback. So we don't need to reset after the callback runs.
ReactCurrentActQueue.didScheduleLegacyUpdate = false;
if (!disableLegacyMode) {
ReactCurrentActQueue.didScheduleLegacyUpdate = false;
}

result = callback();
var didScheduleLegacyUpdate =
ReactCurrentActQueue.didScheduleLegacyUpdate; // Replicate behavior of original `act` implementation in legacy mode,
var didScheduleLegacyUpdate = !disableLegacyMode
? ReactCurrentActQueue.didScheduleLegacyUpdate
: false; // Replicate behavior of original `act` implementation in legacy mode,
// which flushed updates immediately after the scope function exits, even
// if it's an async function.

Expand All @@ -3275,7 +3283,9 @@ if (__DEV__) {
// that's how it worked before version 18. Yes, it's confusing! We should
// delete legacy mode!!

ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
if (!disableLegacyMode) {
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
}
} catch (error) {
// `isBatchingLegacy` gets reset using the regular stack, not the async
// one used to track `act` scopes. Why, you may be wondering? Because
Expand All @@ -3285,7 +3295,10 @@ if (__DEV__) {
}

if (ReactCurrentActQueue.thrownErrors.length > 0) {
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
{
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
}

popActScope(prevActQueue, prevActScopeDepth);
var thrownError = aggregateErrors(ReactCurrentActQueue.thrownErrors);
ReactCurrentActQueue.thrownErrors.length = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5998a775194f491afa5d3badd9afe9ceaf12845e
5de8703646cdd3838cb1686f761b10c0692743aa
Loading

0 comments on commit aac8c4d

Please sign in to comment.