Home / Function/ pushHostContext() — react Function Reference

pushHostContext() — react Function Reference

Architecture documentation for the pushHostContext() function in ReactFiberHostContext.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  a05eb624_1205_fe14_d003_611163eae529["pushHostContext()"]
  0d0aab7d_e6b3_4636_e6ae_2ed95f8e42d0["ReactFiberHostContext.js"]
  a05eb624_1205_fe14_d003_611163eae529 -->|defined in| 0d0aab7d_e6b3_4636_e6ae_2ed95f8e42d0
  53f55fda_e2b6_2801_4fbc_525f8828d23d["updateHostRoot()"]
  53f55fda_e2b6_2801_4fbc_525f8828d23d -->|calls| a05eb624_1205_fe14_d003_611163eae529
  df2c7818_4611_b8d2_dfe8_a79e5972020c["attemptEarlyBailoutIfNoScheduledUpdate()"]
  df2c7818_4611_b8d2_dfe8_a79e5972020c -->|calls| a05eb624_1205_fe14_d003_611163eae529
  d1a95e98_467c_e9b8_af34_7d3813a82b6b["popHostContext()"]
  d1a95e98_467c_e9b8_af34_7d3813a82b6b -->|calls| a05eb624_1205_fe14_d003_611163eae529
  style a05eb624_1205_fe14_d003_611163eae529 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberHostContext.js lines 96–129

function pushHostContext(fiber: Fiber): void {
  const stateHook: Hook | null = fiber.memoizedState;
  if (stateHook !== null) {
    // Propagate the current state to all the descendents.
    // We use Context as an implementation detail for this.
    //
    // NOTE: This assumes that there cannot be nested transition providers,
    // because the only renderer that implements this feature is React DOM,
    // and forms cannot be nested. If we did support nested providers, then
    // we would need to push a context value even for host fibers that
    // haven't been upgraded yet.
    const transitionStatus: TransitionStatus = stateHook.memoizedState;
    if (isPrimaryRenderer) {
      HostTransitionContext._currentValue = transitionStatus;
    } else {
      HostTransitionContext._currentValue2 = transitionStatus;
    }

    // Only provide context if this fiber has been upgraded by a host
    // transition. We use the same optimization for regular host context below.
    push(hostTransitionProviderCursor, fiber, fiber);
  }

  const context: HostContext = requiredContext(contextStackCursor.current);
  const nextContext = getChildHostContext(context, fiber.type);

  // Don't push this Fiber's context unless it's unique.
  if (context !== nextContext) {
    // Track the context and the Fiber that provided it.
    // This enables us to pop only Fibers that provide unique contexts.
    push(contextFiberStackCursor, fiber, fiber);
    push(contextStackCursor, nextContext, fiber);
  }
}

Domain

Subdomains

Frequently Asked Questions

What does pushHostContext() do?
pushHostContext() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberHostContext.js.
Where is pushHostContext() defined?
pushHostContext() is defined in packages/react-reconciler/src/ReactFiberHostContext.js at line 96.
What calls pushHostContext()?
pushHostContext() is called by 3 function(s): attemptEarlyBailoutIfNoScheduledUpdate, popHostContext, updateHostRoot.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free