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

Function popPreviousToCommonLevel

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

Source from the content-addressed store, hash-verified

102}
103
104function popPreviousToCommonLevel(
105 prev: ContextNode<any>,
106 next: ContextNode<any>,
107): void {
108 popNode(prev);
109 const parentPrev = prev.parent;
110
111 if (parentPrev === null) {
112 throw new Error(
113 'The depth must equal at least at zero before reaching the root. This is a bug in React.',
114 );
115 }
116
117 if (parentPrev.depth === next.depth) {
118 // We found the same level. Now we just need to find a shared ancestor.
119 popToNearestCommonAncestor(parentPrev, next);
120 } else {
121 // We must still be deeper.
122 popPreviousToCommonLevel(parentPrev, next);
123 }
124}
125
126function popNextToCommonLevel(
127 prev: ContextNode<any>,

Callers 1

switchContextFunction · 0.85

Calls 2

popNodeFunction · 0.85

Tested by

no test coverage detected