Home / Function/ commitDeletionEffectsOnFiber() — react Function Reference

commitDeletionEffectsOnFiber() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  5af9a16a_ed89_d37e_b847_bcb6a2805eae["commitDeletionEffectsOnFiber()"]
  e0fbfbd5_47b0_a489_0b36_bbfad9245544["ReactFiberCommitWork.js"]
  5af9a16a_ed89_d37e_b847_bcb6a2805eae -->|defined in| e0fbfbd5_47b0_a489_0b36_bbfad9245544
  13f145c1_d686_f120_13ad_212f75386c29["commitDeletionEffects()"]
  13f145c1_d686_f120_13ad_212f75386c29 -->|calls| 5af9a16a_ed89_d37e_b847_bcb6a2805eae
  bc226c47_971c_bf5b_66bf_b301c5a30306["recursivelyTraverseDeletionEffects()"]
  bc226c47_971c_bf5b_66bf_b301c5a30306 -->|calls| 5af9a16a_ed89_d37e_b847_bcb6a2805eae
  bf32bf56_1958_e6b0_1d93_27dbf589f30a["onCommitUnmount()"]
  5af9a16a_ed89_d37e_b847_bcb6a2805eae -->|calls| bf32bf56_1958_e6b0_1d93_27dbf589f30a
  4f76ed87_f151_2295_8bb4_c7b5dfe010a2["pushComponentEffectStart()"]
  5af9a16a_ed89_d37e_b847_bcb6a2805eae -->|calls| 4f76ed87_f151_2295_8bb4_c7b5dfe010a2
  da570743_1675_9fe9_6425_06d6a84f49ba["pushComponentEffectDuration()"]
  5af9a16a_ed89_d37e_b847_bcb6a2805eae -->|calls| da570743_1675_9fe9_6425_06d6a84f49ba
  bc226c47_971c_bf5b_66bf_b301c5a30306["recursivelyTraverseDeletionEffects()"]
  5af9a16a_ed89_d37e_b847_bcb6a2805eae -->|calls| bc226c47_971c_bf5b_66bf_b301c5a30306
  31dbea93_6a15_5a88_2a94_0513d6287f5a["commitHookEffectListUnmount()"]
  5af9a16a_ed89_d37e_b847_bcb6a2805eae -->|calls| 31dbea93_6a15_5a88_2a94_0513d6287f5a
  536f849f_4ed1_3dcd_f2ef_4c117116c0b7["commitHookLayoutUnmountEffects()"]
  5af9a16a_ed89_d37e_b847_bcb6a2805eae -->|calls| 536f849f_4ed1_3dcd_f2ef_4c117116c0b7
  53097c13_f55b_a762_7d12_7c560d2278d9["untrackNamedViewTransition()"]
  5af9a16a_ed89_d37e_b847_bcb6a2805eae -->|calls| 53097c13_f55b_a762_7d12_7c560d2278d9
  ff9409a2_b556_06af_85c9_ee748a528d80["popComponentEffectStart()"]
  5af9a16a_ed89_d37e_b847_bcb6a2805eae -->|calls| ff9409a2_b556_06af_85c9_ee748a528d80
  e047b0ab_3567_71e4_0705_344ee07a23b7["popComponentEffectDuration()"]
  5af9a16a_ed89_d37e_b847_bcb6a2805eae -->|calls| e047b0ab_3567_71e4_0705_344ee07a23b7
  style 5af9a16a_ed89_d37e_b847_bcb6a2805eae fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberCommitWork.js lines 1464–1811

function commitDeletionEffectsOnFiber(
  finishedRoot: FiberRoot,
  nearestMountedAncestor: Fiber,
  deletedFiber: Fiber,
) {
  // TODO: Delete this Hook once new DevTools ships everywhere. No longer needed.
  onCommitUnmount(deletedFiber);

  const prevEffectStart = pushComponentEffectStart();
  const prevEffectDuration = pushComponentEffectDuration();
  const prevEffectErrors = pushComponentEffectErrors();
  const prevEffectDidSpawnUpdate = pushComponentEffectDidSpawnUpdate();

  // The cases in this outer switch modify the stack before they traverse
  // into their subtree. There are simpler cases in the inner switch
  // that don't modify the stack.
  switch (deletedFiber.tag) {
    case HostHoistable: {
      if (supportsResources) {
        if (!offscreenSubtreeWasHidden) {
          safelyDetachRef(deletedFiber, nearestMountedAncestor);
        }
        recursivelyTraverseDeletionEffects(
          finishedRoot,
          nearestMountedAncestor,
          deletedFiber,
        );
        if (deletedFiber.memoizedState) {
          releaseResource(deletedFiber.memoizedState);
        } else if (deletedFiber.stateNode) {
          unmountHoistable(deletedFiber.stateNode);
        }
        break;
      }
      // Fall through
    }
    case HostSingleton: {
      if (supportsSingletons) {
        if (!offscreenSubtreeWasHidden) {
          safelyDetachRef(deletedFiber, nearestMountedAncestor);
        }

        const prevHostParent = hostParent;
        const prevHostParentIsContainer = hostParentIsContainer;
        if (isSingletonScope(deletedFiber.type)) {
          hostParent = deletedFiber.stateNode;
          hostParentIsContainer = false;
        }
        recursivelyTraverseDeletionEffects(
          finishedRoot,
          nearestMountedAncestor,
          deletedFiber,
        );

        // Normally this is called in passive unmount effect phase however with
        // HostSingleton we warn if you acquire one that is already associated to
        // a different fiber. To increase our chances of avoiding this, specifically
        // if you keyed a HostSingleton so there will be a delete followed by a Placement
        // we treat detach eagerly here
        commitHostSingletonRelease(deletedFiber);

        hostParent = prevHostParent;
        hostParentIsContainer = prevHostParentIsContainer;

        break;
      }
      // Fall through
    }
    case HostComponent: {
      if (!offscreenSubtreeWasHidden) {
        safelyDetachRef(deletedFiber, nearestMountedAncestor);
      }
      if (enableFragmentRefs && deletedFiber.tag === HostComponent) {
        commitFragmentInstanceDeletionEffects(deletedFiber);
      }
      // Intentional fallthrough to next branch
    }
    case HostText: {
      // We only need to remove the nearest host child. Set the host parent
      // to `null` on the stack to indicate that nested children don't
      // need to be removed.

Domain

Subdomains

Frequently Asked Questions

What does commitDeletionEffectsOnFiber() do?
commitDeletionEffectsOnFiber() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberCommitWork.js.
Where is commitDeletionEffectsOnFiber() defined?
commitDeletionEffectsOnFiber() is defined in packages/react-reconciler/src/ReactFiberCommitWork.js at line 1464.
What does commitDeletionEffectsOnFiber() call?
commitDeletionEffectsOnFiber() calls 9 function(s): commitHookEffectListUnmount, commitHookLayoutUnmountEffects, onCommitUnmount, popComponentEffectDuration, popComponentEffectStart, pushComponentEffectDuration, pushComponentEffectStart, recursivelyTraverseDeletionEffects, and 1 more.
What calls commitDeletionEffectsOnFiber()?
commitDeletionEffectsOnFiber() is called by 2 function(s): commitDeletionEffects, recursivelyTraverseDeletionEffects.

Analyze Your Own Codebase

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

Try Supermodel Free