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

Function pushHostContext

packages/react-reconciler/src/ReactFiberHostContext.js:92–110  ·  view source on GitHub ↗
(fiber: Fiber)

Source from the content-addressed store, hash-verified

90}
91
92function pushHostContext(fiber: Fiber): void {
93 const stateHook: Hook | null = fiber.memoizedState;
94 if (stateHook !== null) {
95 // Only provide context if this fiber has been upgraded by a host
96 // transition. We use the same optimization for regular host context below.
97 push(hostTransitionProviderCursor, fiber, fiber);
98 }
99
100 const context: HostContext = requiredContext(contextStackCursor.current);
101 const nextContext = getChildHostContext(context, fiber.type);
102
103 // Don't push this Fiber's context unless it's unique.
104 if (context !== nextContext) {
105 // Track the context and the Fiber that provided it.
106 // This enables us to pop only Fibers that provide unique contexts.
107 push(contextFiberStackCursor, fiber, fiber);
108 push(contextStackCursor, nextContext, fiber);
109 }
110}
111
112function popHostContext(fiber: Fiber): void {
113 if (contextFiberStackCursor.current === fiber) {

Callers 3

updateHostComponentFunction · 0.90
updateHostSingletonFunction · 0.90

Calls 3

pushFunction · 0.90
getChildHostContextFunction · 0.90
requiredContextFunction · 0.85

Tested by

no test coverage detected