Home / Function/ appendAllChildrenToContainer() — react Function Reference

appendAllChildrenToContainer() — react Function Reference

Architecture documentation for the appendAllChildrenToContainer() function in ReactFiberCompleteWork.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  d6e3ac5e_f6c5_98d7_de25_cdce6cf422bc["appendAllChildrenToContainer()"]
  6b05669d_2f09_63a5_e79f_0afc195f25a3["ReactFiberCompleteWork.js"]
  d6e3ac5e_f6c5_98d7_de25_cdce6cf422bc -->|defined in| 6b05669d_2f09_63a5_e79f_0afc195f25a3
  3cccd78e_6f36_bda1_da89_ea302f4aca1a["updateHostContainer()"]
  3cccd78e_6f36_bda1_da89_ea302f4aca1a -->|calls| d6e3ac5e_f6c5_98d7_de25_cdce6cf422bc
  17f65ca7_1e68_0419_b46a_9bf4b1b54b06["updateHostComponent()"]
  17f65ca7_1e68_0419_b46a_9bf4b1b54b06 -->|calls| d6e3ac5e_f6c5_98d7_de25_cdce6cf422bc
  style d6e3ac5e_f6c5_98d7_de25_cdce6cf422bc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberCompleteWork.js lines 349–428

function appendAllChildrenToContainer(
  containerChildSet: ChildSet,
  workInProgress: Fiber,
  needsVisibilityToggle: boolean,
  isHidden: boolean,
): boolean {
  // Host components that have their visibility toggled by an OffscreenComponent
  // do not support passChildrenWhenCloningPersistedNodes. To inform the callee
  // about their presence, we track and return if they were added to the
  // child set.
  let hasOffscreenComponentChild = false;
  if (supportsPersistence) {
    // We only have the top Fiber that was created but we need recurse down its
    // children to find all the terminal nodes.
    let node = workInProgress.child;
    while (node !== null) {
      if (node.tag === HostComponent) {
        let instance = node.stateNode;
        if (needsVisibilityToggle && isHidden) {
          // This child is inside a timed out tree. Hide it.
          const props = node.memoizedProps;
          const type = node.type;
          instance = cloneHiddenInstance(instance, type, props);
        }
        appendChildToContainerChildSet(containerChildSet, instance);
      } else if (node.tag === HostText) {
        let instance = node.stateNode;
        if (needsVisibilityToggle && isHidden) {
          // This child is inside a timed out tree. Hide it.
          const text = node.memoizedProps;
          instance = cloneHiddenTextInstance(instance, text);
        }
        appendChildToContainerChildSet(containerChildSet, instance);
      } else if (node.tag === HostPortal) {
        // If we have a portal child, then we don't want to traverse
        // down its children. Instead, we'll get insertions from each child in
        // the portal directly.
      } else if (
        node.tag === OffscreenComponent &&
        node.memoizedState !== null
      ) {
        // The children in this boundary are hidden. Toggle their visibility
        // before appending.
        const child = node.child;
        if (child !== null) {
          child.return = node;
        }
        appendAllChildrenToContainer(
          containerChildSet,
          node,
          /* needsVisibilityToggle */ true,
          /* isHidden */ true,
        );

        hasOffscreenComponentChild = true;
      } else if (node.child !== null) {
        node.child.return = node;
        node = node.child;
        continue;
      }
      node = (node: Fiber);
      if (node === workInProgress) {
        return hasOffscreenComponentChild;
      }
      // $FlowFixMe[incompatible-use] found when upgrading Flow
      while (node.sibling === null) {
        // $FlowFixMe[incompatible-use] found when upgrading Flow
        if (node.return === null || node.return === workInProgress) {
          return hasOffscreenComponentChild;
        }
        node = node.return;
      }
      // $FlowFixMe[incompatible-use] found when upgrading Flow
      node.sibling.return = node.return;
      node = node.sibling;
    }
  }

  return hasOffscreenComponentChild;
}

Domain

Subdomains

Frequently Asked Questions

What does appendAllChildrenToContainer() do?
appendAllChildrenToContainer() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberCompleteWork.js.
Where is appendAllChildrenToContainer() defined?
appendAllChildrenToContainer() is defined in packages/react-reconciler/src/ReactFiberCompleteWork.js at line 349.
What calls appendAllChildrenToContainer()?
appendAllChildrenToContainer() is called by 2 function(s): updateHostComponent, updateHostContainer.

Analyze Your Own Codebase

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

Try Supermodel Free