Home / Function/ detachFiberAfterEffects() — react Function Reference

detachFiberAfterEffects() — react Function Reference

Architecture documentation for the detachFiberAfterEffects() function in ReactFiberCommitWork.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  a393bc4d_dd4d_c1e2_11c7_048b31d80593["detachFiberAfterEffects()"]
  e0fbfbd5_47b0_a489_0b36_bbfad9245544["ReactFiberCommitWork.js"]
  a393bc4d_dd4d_c1e2_11c7_048b31d80593 -->|defined in| e0fbfbd5_47b0_a489_0b36_bbfad9245544
  cf9f6da8_dd94_460c_451a_95fb5e125105["commitPassiveUnmountEffectsInsideOfDeletedTree_complete()"]
  cf9f6da8_dd94_460c_451a_95fb5e125105 -->|calls| a393bc4d_dd4d_c1e2_11c7_048b31d80593
  style a393bc4d_dd4d_c1e2_11c7_048b31d80593 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberCommitWork.js lines 1309–1353

function detachFiberAfterEffects(fiber: Fiber) {
  const alternate = fiber.alternate;
  if (alternate !== null) {
    fiber.alternate = null;
    detachFiberAfterEffects(alternate);
  }

  // Clear cyclical Fiber fields. This level alone is designed to roughly
  // approximate the planned Fiber refactor. In that world, `setState` will be
  // bound to a special "instance" object instead of a Fiber. The Instance
  // object will not have any of these fields. It will only be connected to
  // the fiber tree via a single link at the root. So if this level alone is
  // sufficient to fix memory issues, that bodes well for our plans.
  fiber.child = null;
  fiber.deletions = null;
  fiber.sibling = null;

  // The `stateNode` is cyclical because on host nodes it points to the host
  // tree, which has its own pointers to children, parents, and siblings.
  // The other host nodes also point back to fibers, so we should detach that
  // one, too.
  if (fiber.tag === HostComponent) {
    const hostInstance: Instance = fiber.stateNode;
    if (hostInstance !== null) {
      detachDeletedInstance(hostInstance);
    }
  }
  fiber.stateNode = null;

  if (__DEV__) {
    fiber._debugOwner = null;
  }

  // Theoretically, nothing in here should be necessary, because we already
  // disconnected the fiber from the tree. So even if something leaks this
  // particular fiber, it won't leak anything else.
  fiber.return = null;
  fiber.dependencies = null;
  fiber.memoizedProps = null;
  fiber.memoizedState = null;
  fiber.pendingProps = null;
  fiber.stateNode = null;
  // TODO: Move to `commitPassiveUnmountInsideDeletedTreeOnFiber` instead.
  fiber.updateQueue = null;
}

Domain

Subdomains

Frequently Asked Questions

What does detachFiberAfterEffects() do?
detachFiberAfterEffects() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberCommitWork.js.
Where is detachFiberAfterEffects() defined?
detachFiberAfterEffects() is defined in packages/react-reconciler/src/ReactFiberCommitWork.js at line 1309.
What calls detachFiberAfterEffects()?
detachFiberAfterEffects() is called by 1 function(s): commitPassiveUnmountEffectsInsideOfDeletedTree_complete.

Analyze Your Own Codebase

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

Try Supermodel Free