Skip to content

Commit ffd8102

Browse files
committed
Avoid closure
Fixes ```` SyntaxError: ~/react/packages/react-reconciler/src/ReactFiberLane.js: Compiling let/const in this block would add a closure (throwIfClosureRequired). 614 | if (updateLane !== IdleLane) { 615 | if (enableUpdaterTracking) { > 616 | if (isDevToolsPresent) { | ^ 617 | // transfer pending updaters from pingedLanes to updateLane 618 | const pendingUpdatersLaneMap = root.pendingUpdatersLaneMap; 619 | const updaters = pendingUpdatersLaneMap[laneToIndex(updateLane)]; ```
1 parent 2abf6dc commit ffd8102

File tree

2 files changed

+31
-35
lines changed

2 files changed

+31
-35
lines changed

packages/react-reconciler/src/ReactFiberLane.js

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -625,26 +625,7 @@ export function markRootUpdated(root: FiberRoot, updateLane: Lane) {
625625
// idle updates until after all the regular updates have finished; there's no
626626
// way it could unblock a transition.
627627
if (updateLane !== IdleLane) {
628-
if (enableUpdaterTracking) {
629-
if (isDevToolsPresent) {
630-
// transfer pending updaters from pingedLanes to updateLane
631-
const pendingUpdatersLaneMap = root.pendingUpdatersLaneMap;
632-
const updaters = pendingUpdatersLaneMap[laneToIndex(updateLane)];
633-
let lanes = root.pingedLanes;
634-
while (lanes > 0) {
635-
const index = laneToIndex(lanes);
636-
const lane = 1 << index;
637-
638-
const pingedUpdaters = pendingUpdatersLaneMap[index];
639-
pingedUpdaters.forEach(pingedUpdater => {
640-
updaters.add(pingedUpdater);
641-
});
642-
pingedUpdaters.clear();
643-
644-
lanes &= ~lane;
645-
}
646-
}
647-
}
628+
movePendingUpdatersToLane(root, root.pingedLanes, updateLane);
648629

649630
root.suspendedLanes = NoLanes;
650631
root.pingedLanes = NoLanes;
@@ -927,6 +908,35 @@ export function addFiberToLanesMap(
927908
}
928909
}
929910

911+
function movePendingUpdatersToLane(
912+
root: FiberRoot,
913+
sourceLanes: Lanes,
914+
targetLane: Lane,
915+
) {
916+
if (!enableUpdaterTracking) {
917+
return;
918+
}
919+
if (!isDevToolsPresent) {
920+
return;
921+
}
922+
const pendingUpdatersLaneMap = root.pendingUpdatersLaneMap;
923+
const targetIndex = laneToIndex(targetLane)
924+
const targetUpdaters = pendingUpdatersLaneMap[targetIndex];
925+
let lanes = sourceLanes;
926+
while (lanes > 0) {
927+
const index = laneToIndex(lanes);
928+
const lane = 1 << index;
929+
930+
const sourceUpdaters = pendingUpdatersLaneMap[index];
931+
sourceUpdaters.forEach(sourceUpdater => {
932+
targetUpdaters.add(sourceUpdater);
933+
});
934+
sourceUpdaters.clear();
935+
936+
lanes &= ~lane;
937+
}
938+
}
939+
930940
export function movePendingFibersToMemoized(root: FiberRoot, lanes: Lanes) {
931941
if (!enableUpdaterTracking) {
932942
return;

packages/shared/ReactVersion.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1 @@
1-
/**
2-
* Copyright (c) Meta Platforms, Inc. and affiliates.
3-
*
4-
* This source code is licensed under the MIT license found in the
5-
* LICENSE file in the root directory of this source tree.
6-
*/
7-
8-
// TODO: this is special because it gets imported during build.
9-
//
10-
// It exists as a placeholder so that DevTools can support work tag changes between releases.
11-
// When we next publish a release, update the matching TODO in backend/renderer.js
12-
// TODO: This module is used both by the release scripts and to expose a version
13-
// at runtime. We should instead inject the version number as part of the build
14-
// process, and use the ReactVersions.js module as the single source of truth.
15-
export default '19.0.0';
1+
export default '19.0.0-rc-2abf6dc841-20240602';

0 commit comments

Comments
 (0)