Skip to content

Commit

Permalink
Avoid closure
Browse files Browse the repository at this point in the history
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)];
  ```
  • Loading branch information
eps1lon committed Jun 2, 2024
1 parent 2abf6dc commit ffd8102
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 35 deletions.
50 changes: 30 additions & 20 deletions packages/react-reconciler/src/ReactFiberLane.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,26 +625,7 @@ export function markRootUpdated(root: FiberRoot, updateLane: Lane) {
// idle updates until after all the regular updates have finished; there's no
// way it could unblock a transition.
if (updateLane !== IdleLane) {
if (enableUpdaterTracking) {
if (isDevToolsPresent) {
// transfer pending updaters from pingedLanes to updateLane
const pendingUpdatersLaneMap = root.pendingUpdatersLaneMap;
const updaters = pendingUpdatersLaneMap[laneToIndex(updateLane)];
let lanes = root.pingedLanes;
while (lanes > 0) {
const index = laneToIndex(lanes);
const lane = 1 << index;

const pingedUpdaters = pendingUpdatersLaneMap[index];
pingedUpdaters.forEach(pingedUpdater => {
updaters.add(pingedUpdater);
});
pingedUpdaters.clear();

lanes &= ~lane;
}
}
}
movePendingUpdatersToLane(root, root.pingedLanes, updateLane);

root.suspendedLanes = NoLanes;
root.pingedLanes = NoLanes;
Expand Down Expand Up @@ -927,6 +908,35 @@ export function addFiberToLanesMap(
}
}

function movePendingUpdatersToLane(
root: FiberRoot,
sourceLanes: Lanes,
targetLane: Lane,
) {
if (!enableUpdaterTracking) {
return;
}
if (!isDevToolsPresent) {
return;
}
const pendingUpdatersLaneMap = root.pendingUpdatersLaneMap;
const targetIndex = laneToIndex(targetLane)
const targetUpdaters = pendingUpdatersLaneMap[targetIndex];
let lanes = sourceLanes;
while (lanes > 0) {
const index = laneToIndex(lanes);
const lane = 1 << index;

const sourceUpdaters = pendingUpdatersLaneMap[index];
sourceUpdaters.forEach(sourceUpdater => {
targetUpdaters.add(sourceUpdater);
});
sourceUpdaters.clear();

lanes &= ~lane;
}
}

export function movePendingFibersToMemoized(root: FiberRoot, lanes: Lanes) {
if (!enableUpdaterTracking) {
return;
Expand Down
16 changes: 1 addition & 15 deletions packages/shared/ReactVersion.js
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

// TODO: this is special because it gets imported during build.
//
// It exists as a placeholder so that DevTools can support work tag changes between releases.
// When we next publish a release, update the matching TODO in backend/renderer.js
// TODO: This module is used both by the release scripts and to expose a version
// at runtime. We should instead inject the version number as part of the build
// process, and use the ReactVersions.js module as the single source of truth.
export default '19.0.0';
export default '19.0.0-rc-2abf6dc841-20240602';

0 comments on commit ffd8102

Please sign in to comment.