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 6a2add4
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 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,34 @@ export function addFiberToLanesMap(
}
}

function movePendingUpdatersToLane(
root: FiberRoot,
sourceLanes: Lanes,
targetLane: Lane,
) {
if (!enableUpdaterTracking) {
return;
}
if (!isDevToolsPresent) {
return;
}
const pendingUpdatersLaneMap = root.pendingUpdatersLaneMap;
const targetUpdaters = pendingUpdatersLaneMap[laneToIndex(targetLane)];
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

0 comments on commit 6a2add4

Please sign in to comment.