Home / Function/ commitBeforeMutationEffectsOnFiber() — react Function Reference

commitBeforeMutationEffectsOnFiber() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  ea3bf626_4e45_2dc4_e991_d010004126f3["commitBeforeMutationEffectsOnFiber()"]
  e0fbfbd5_47b0_a489_0b36_bbfad9245544["ReactFiberCommitWork.js"]
  ea3bf626_4e45_2dc4_e991_d010004126f3 -->|defined in| e0fbfbd5_47b0_a489_0b36_bbfad9245544
  68273476_fee5_f7ba_e142_f9c1d94ed124["commitBeforeMutationEffects_complete()"]
  68273476_fee5_f7ba_e142_f9c1d94ed124 -->|calls| ea3bf626_4e45_2dc4_e991_d010004126f3
  46196775_b72d_8de6_8872_11eefbbe57d1["isSuspenseBoundaryBeingHidden()"]
  ea3bf626_4e45_2dc4_e991_d010004126f3 -->|calls| 46196775_b72d_8de6_8872_11eefbbe57d1
  c0a65d94_b34a_97ec_7298_10d943a24e28["doesFiberContain()"]
  ea3bf626_4e45_2dc4_e991_d010004126f3 -->|calls| c0a65d94_b34a_97ec_7298_10d943a24e28
  style ea3bf626_4e45_2dc4_e991_d010004126f3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberCommitWork.js lines 475–570

function commitBeforeMutationEffectsOnFiber(
  finishedWork: Fiber,
  isViewTransitionEligible: boolean,
) {
  const current = finishedWork.alternate;
  const flags = finishedWork.flags;

  if (enableCreateEventHandleAPI) {
    if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) {
      // Check to see if the focused element was inside of a hidden (Suspense) subtree.
      // TODO: Move this out of the hot path using a dedicated effect tag.
      // TODO: This should consider Offscreen in general and not just SuspenseComponent.
      if (
        finishedWork.tag === SuspenseComponent &&
        isSuspenseBoundaryBeingHidden(current, finishedWork) &&
        // $FlowFixMe[incompatible-call] found when upgrading Flow
        doesFiberContain(finishedWork, focusedInstanceHandle)
      ) {
        shouldFireAfterActiveInstanceBlur = true;
        beforeActiveInstanceBlur(finishedWork);
      }
    }
  }

  switch (finishedWork.tag) {
    case FunctionComponent:
    case ForwardRef:
    case SimpleMemoComponent: {
      if (!enableEffectEventMutationPhase && (flags & Update) !== NoFlags) {
        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;
          }
        }
      }
      break;
    }
    case ClassComponent: {
      if ((flags & Snapshot) !== NoFlags) {
        if (current !== null) {
          commitClassSnapshot(finishedWork, current);
        }
      }
      break;
    }
    case HostRoot: {
      if ((flags & Snapshot) !== NoFlags) {
        if (supportsMutation) {
          const root = finishedWork.stateNode;
          clearContainer(root.containerInfo);
        }
      }
      break;
    }
    case HostComponent:
    case HostHoistable:
    case HostSingleton:
    case HostText:
    case HostPortal:
    case IncompleteClassComponent:
      // Nothing to do for these component types
      break;
    case ViewTransitionComponent:
      if (enableViewTransition) {
        if (isViewTransitionEligible) {
          if (current === null) {
            // This is a new mount. We should have handled this as part of the
            // Placement effect or it is deeper inside a entering transition.
          } else {
            // Something may have mutated within this subtree. This might need to cause
            // a cross-fade of this parent. We first assign old names to the
            // previous tree in the before mutation phase in case we need to.
            // TODO: This walks the tree that we might continue walking anyway.
            // We should just stash the parent ViewTransitionComponent and continue
            // walking the tree until we find HostComponent but to do that we need
            // to use a stack which requires refactoring this phase.
            commitBeforeUpdateViewTransition(current, finishedWork);

Domain

Subdomains

Frequently Asked Questions

What does commitBeforeMutationEffectsOnFiber() do?
commitBeforeMutationEffectsOnFiber() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberCommitWork.js.
Where is commitBeforeMutationEffectsOnFiber() defined?
commitBeforeMutationEffectsOnFiber() is defined in packages/react-reconciler/src/ReactFiberCommitWork.js at line 475.
What does commitBeforeMutationEffectsOnFiber() call?
commitBeforeMutationEffectsOnFiber() calls 2 function(s): doesFiberContain, isSuspenseBoundaryBeingHidden.
What calls commitBeforeMutationEffectsOnFiber()?
commitBeforeMutationEffectsOnFiber() is called by 1 function(s): commitBeforeMutationEffects_complete.

Analyze Your Own Codebase

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

Try Supermodel Free