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

Function popNextToCommonLevel

packages/react-server/src/ReactFizzNewContext.js:126–146  ·  view source on GitHub ↗
(
  prev: ContextNode<any>,
  next: ContextNode<any>,
)

Source from the content-addressed store, hash-verified

124}
125
126function popNextToCommonLevel(
127 prev: ContextNode<any>,
128 next: ContextNode<any>,
129): void {
130 const parentNext = next.parent;
131
132 if (parentNext === null) {
133 throw new Error(
134 'The depth must equal at least at zero before reaching the root. This is a bug in React.',
135 );
136 }
137
138 if (prev.depth === parentNext.depth) {
139 // We found the same level. Now we just need to find a shared ancestor.
140 popToNearestCommonAncestor(prev, parentNext);
141 } else {
142 // We must still be deeper.
143 popNextToCommonLevel(prev, parentNext);
144 }
145 pushNode(next);
146}
147
148// Perform context switching to the new snapshot.
149// To make it cheap to read many contexts, while not suspending, we make the switch eagerly by

Callers 1

switchContextFunction · 0.85

Calls 2

pushNodeFunction · 0.85

Tested by

no test coverage detected