Skip to content

Commit

Permalink
Move ReactDOMLegacy implementation into RootFB (#28656)
Browse files Browse the repository at this point in the history
Only the FB entry point has legacy mode now so we can move the remaining
code in there.

Also enable disableLegacyMode in modern www builds since it doesn't
expose those entry points.

Now dependent on #28709.

---------

Co-authored-by: Josh Story <story@hey.com>

DiffTrain build for [8f55a6a](8f55a6a)
  • Loading branch information
sebmarkbage committed Apr 3, 2024
1 parent 72e3e57 commit 2a92b78
Show file tree
Hide file tree
Showing 14 changed files with 118,717 additions and 122,051 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5de8703646cdd3838cb1686f761b10c0692743aa
8f55a6aa5739ed8ca80c3066fb54f4ea4cfe600a
25 changes: 5 additions & 20 deletions compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (__DEV__) {
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = "19.0.0-www-modern-e4b79a21";
var ReactVersion = "19.0.0-www-modern-cf1ffacc";

// ATTENTION
// When adding new symbols to this file,
Expand Down Expand Up @@ -404,7 +404,7 @@ if (__DEV__) {
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp;
// On WWW, true is used for a new modern build.
var disableLegacyMode = false;
var disableLegacyMode = true;

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down Expand Up @@ -3272,19 +3272,12 @@ if (__DEV__) {
// `act` calls can be nested.
//
// If we're already inside an `act` scope, reuse the existing queue.
var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;
var prevIsBatchingLegacy = false;
var prevActQueue = ReactCurrentActQueue.current;
var prevActScopeDepth = actScopeDepth;
actScopeDepth++;
var queue = (ReactCurrentActQueue.current =
prevActQueue !== null ? prevActQueue : []); // Used to reproduce behavior of `batchedUpdates` in legacy mode. Only
// set to `true` while the given callback is executed, not for updates
// triggered during an async event, because this is how the legacy
// implementation of `act` behaved.

{
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 @@ -3295,9 +3288,7 @@ 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.
if (!disableLegacyMode) {
ReactCurrentActQueue.didScheduleLegacyUpdate = false;
}
if (!disableLegacyMode);

result = callback();
var didScheduleLegacyUpdate = !disableLegacyMode
Expand All @@ -3313,9 +3304,7 @@ if (__DEV__) {
// that's how it worked before version 18. Yes, it's confusing! We should
// delete legacy mode!!

if (!disableLegacyMode) {
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
}
if (!disableLegacyMode);
} 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 @@ -3325,10 +3314,6 @@ if (__DEV__) {
}

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

popActScope(prevActQueue, prevActScopeDepth);
var thrownError = aggregateErrors(ReactCurrentActQueue.thrownErrors);
ReactCurrentActQueue.thrownErrors.length = 0;
Expand Down
Loading

0 comments on commit 2a92b78

Please sign in to comment.