Home / Function/ commitMutationEffectsOnFiber() — react Function Reference

commitMutationEffectsOnFiber() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  bc4a6de9_07dc_eca7_681a_10f692e08483["commitMutationEffectsOnFiber()"]
  e0fbfbd5_47b0_a489_0b36_bbfad9245544["ReactFiberCommitWork.js"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|defined in| e0fbfbd5_47b0_a489_0b36_bbfad9245544
  9cf3cbc1_31df_73ff_02fe_9dd2f726e670["commitMutationEffects()"]
  9cf3cbc1_31df_73ff_02fe_9dd2f726e670 -->|calls| bc4a6de9_07dc_eca7_681a_10f692e08483
  c588ccff_afbe_0cc8_1f99_6d2d5c3a7a99["recursivelyTraverseMutationEffects()"]
  c588ccff_afbe_0cc8_1f99_6d2d5c3a7a99 -->|calls| bc4a6de9_07dc_eca7_681a_10f692e08483
  4f76ed87_f151_2295_8bb4_c7b5dfe010a2["pushComponentEffectStart()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| 4f76ed87_f151_2295_8bb4_c7b5dfe010a2
  da570743_1675_9fe9_6425_06d6a84f49ba["pushComponentEffectDuration()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| da570743_1675_9fe9_6425_06d6a84f49ba
  c588ccff_afbe_0cc8_1f99_6d2d5c3a7a99["recursivelyTraverseMutationEffects()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| c588ccff_afbe_0cc8_1f99_6d2d5c3a7a99
  bfb913d8_8b2b_3d32_b3a0_5abb1f979898["commitReconciliationEffects()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| bfb913d8_8b2b_3d32_b3a0_5abb1f979898
  31dbea93_6a15_5a88_2a94_0513d6287f5a["commitHookEffectListUnmount()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| 31dbea93_6a15_5a88_2a94_0513d6287f5a
  9fd588c7_bccc_26bc_b726_517f00094e4a["commitHookEffectListMount()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| 9fd588c7_bccc_26bc_b726_517f00094e4a
  536f849f_4ed1_3dcd_f2ef_4c117116c0b7["commitHookLayoutUnmountEffects()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| 536f849f_4ed1_3dcd_f2ef_4c117116c0b7
  ce3d630c_843e_17fd_117d_67410066cc99["commitHostUpdate()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| ce3d630c_843e_17fd_117d_67410066cc99
  611dd918_1f79_6852_bb75_eadf21894f4e["commitHostResetTextContent()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| 611dd918_1f79_6852_bb75_eadf21894f4e
  eadbfdbc_c27b_7254_4c85_e7091d8d380e["commitHostTextUpdate()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| eadbfdbc_c27b_7254_4c85_e7091d8d380e
  0173a090_1c78_3da9_68fd_5bfa21600acc["pushNestedEffectDurations()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| 0173a090_1c78_3da9_68fd_5bfa21600acc
  82dffb4f_5067_14c8_9f76_18d5be1ab6e1["pushRootMutationContext()"]
  bc4a6de9_07dc_eca7_681a_10f692e08483 -->|calls| 82dffb4f_5067_14c8_9f76_18d5be1ab6e1
  style bc4a6de9_07dc_eca7_681a_10f692e08483 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberCommitWork.js lines 2026–2616

function commitMutationEffectsOnFiber(
  finishedWork: Fiber,
  root: FiberRoot,
  lanes: Lanes,
) {
  const prevEffectStart = pushComponentEffectStart();
  const prevEffectDuration = pushComponentEffectDuration();
  const prevEffectErrors = pushComponentEffectErrors();
  const prevEffectDidSpawnUpdate = pushComponentEffectDidSpawnUpdate();
  const current = finishedWork.alternate;
  const flags = finishedWork.flags;

  // The effect flag should be checked *after* we refine the type of fiber,
  // because the fiber tag is more specific. An exception is any flag related
  // to reconciliation, because those can be set on all fiber types.
  switch (finishedWork.tag) {
    case FunctionComponent:
    case ForwardRef:
    case MemoComponent:
    case SimpleMemoComponent: {
      // Mutate event effect callbacks on the way down, before mutation effects.
      // This ensures that parent event effects are mutated before child effects.
      // This isn't a supported use case, so we can re-consider it,
      // but this was the behavior we originally shipped.
      if (enableEffectEventMutationPhase) {
        if (flags & Update) {
          const updateQueue: FunctionComponentUpdateQueue | null =
            (finishedWork.updateQueue: any);
          const eventPayloads =
            updateQueue !== null ? updateQueue.events : null;
          if (eventPayloads !== null) {
            for (let ii = 0; ii < eventPayloads.length; ii++) {
              const {ref, nextImpl} = eventPayloads[ii];
              ref.impl = nextImpl;
            }
          }
        }
      }
      recursivelyTraverseMutationEffects(root, finishedWork, lanes);
      commitReconciliationEffects(finishedWork, lanes);

      if (flags & Update) {
        commitHookEffectListUnmount(
          HookInsertion | HookHasEffect,
          finishedWork,
          finishedWork.return,
        );
        // TODO: Use a commitHookInsertionUnmountEffects wrapper to record timings.
        commitHookEffectListMount(HookInsertion | HookHasEffect, finishedWork);
        commitHookLayoutUnmountEffects(
          finishedWork,
          finishedWork.return,
          HookLayout | HookHasEffect,
        );
      }
      break;
    }
    case ClassComponent: {
      recursivelyTraverseMutationEffects(root, finishedWork, lanes);
      commitReconciliationEffects(finishedWork, lanes);

      if (flags & Ref) {
        if (!offscreenSubtreeWasHidden && current !== null) {
          safelyDetachRef(current, current.return);
        }
      }

      if (flags & Callback && offscreenSubtreeIsHidden) {
        const updateQueue: UpdateQueue<mixed> | null =
          (finishedWork.updateQueue: any);
        if (updateQueue !== null) {
          deferHiddenCallbacks(updateQueue);
        }
      }
      break;
    }
    case HostHoistable: {
      if (supportsResources) {
        // We cast because we always set the root at the React root and so it cannot be
        // null while we are processing mutation effects
        const hoistableRoot: HoistableRoot = (currentHoistableRoot: any);

Domain

Subdomains

Frequently Asked Questions

What does commitMutationEffectsOnFiber() do?
commitMutationEffectsOnFiber() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberCommitWork.js.
Where is commitMutationEffectsOnFiber() defined?
commitMutationEffectsOnFiber() is defined in packages/react-reconciler/src/ReactFiberCommitWork.js at line 2026.
What does commitMutationEffectsOnFiber() call?
commitMutationEffectsOnFiber() calls 22 function(s): attachSuspenseRetryListeners, bubbleNestedEffectDurations, commitHookEffectListMount, commitHookEffectListUnmount, commitHookLayoutUnmountEffects, commitHostResetTextContent, commitHostTextUpdate, commitHostUpdate, and 14 more.
What calls commitMutationEffectsOnFiber()?
commitMutationEffectsOnFiber() is called by 2 function(s): commitMutationEffects, recursivelyTraverseMutationEffects.

Analyze Your Own Codebase

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

Try Supermodel Free