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

Function pushHostContainer

packages/react-reconciler/src/ReactFiberHostContext.js:61–79  ·  view source on GitHub ↗
(fiber: Fiber, nextRootInstance: Container)

Source from the content-addressed store, hash-verified

59}
60
61function pushHostContainer(fiber: Fiber, nextRootInstance: Container): void {
62 // Push current root instance onto the stack;
63 // This allows us to reset root when portals are popped.
64 push(rootInstanceStackCursor, nextRootInstance, fiber);
65 // Track the context and the Fiber that provided it.
66 // This enables us to pop only Fibers that provide unique contexts.
67 push(contextFiberStackCursor, fiber, fiber);
68
69 // Finally, we need to push the host context to the stack.
70 // However, we can't just call getRootHostContext() and push it because
71 // we'd have a different number of entries on the stack depending on
72 // whether getRootHostContext() throws somewhere in renderer code or not.
73 // So we push an empty value first. This lets us safely unwind on errors.
74 push(contextStackCursor, null, fiber);
75 const nextRootContext = getRootHostContext(nextRootInstance);
76 // Now that we know this function doesn't throw, replace it.
77 pop(contextStackCursor, fiber);
78 push(contextStackCursor, nextRootContext, fiber);
79}
80
81function popHostContainer(fiber: Fiber) {
82 pop(contextStackCursor, fiber);

Callers 3

pushHostRootContextFunction · 0.90
updatePortalComponentFunction · 0.90

Calls 3

pushFunction · 0.90
getRootHostContextFunction · 0.90
popFunction · 0.90

Tested by

no test coverage detected