MCPcopy
hub / github.com/facebook/react / markRootEntangled

Function markRootEntangled

packages/react-reconciler/src/ReactFiberLane.js:1022–1051  ·  view source on GitHub ↗
(root: FiberRoot, entangledLanes: Lanes)

Source from the content-addressed store, hash-verified

1020}
1021
1022export function markRootEntangled(root: FiberRoot, entangledLanes: Lanes) {
1023 // In addition to entangling each of the given lanes with each other, we also
1024 // have to consider _transitive_ entanglements. For each lane that is already
1025 // entangled with *any* of the given lanes, that lane is now transitively
1026 // entangled with *all* the given lanes.
1027 //
1028 // Translated: If C is entangled with A, then entangling A with B also
1029 // entangles C with B.
1030 //
1031 // If this is hard to grasp, it might help to intentionally break this
1032 // function and look at the tests that fail in ReactTransition-test.js. Try
1033 // commenting out one of the conditions below.
1034
1035 const rootEntangledLanes = (root.entangledLanes |= entangledLanes);
1036 const entanglements = root.entanglements;
1037 let lanes = rootEntangledLanes;
1038 while (lanes) {
1039 const index = pickArbitraryLaneIndex(lanes);
1040 const lane = 1 << index;
1041 if (
1042 // Is this one of the newly entangled lanes?
1043 (lane & entangledLanes) |
1044 // Is this lane transitively entangled with the newly entangled lanes?
1045 (entanglements[index] & entangledLanes)
1046 ) {
1047 entanglements[index] |= entangledLanes;
1048 }
1049 lanes &= ~lane;
1050 }
1051}
1052
1053export function upgradePendingLanesToSync(
1054 root: FiberRoot,

Callers 2

ReactFiberHooks.jsFile · 0.90
entangleTransitionsFunction · 0.90

Calls 1

pickArbitraryLaneIndexFunction · 0.85

Tested by

no test coverage detected