Home / Function/ commitBeforeMutationEffects_begin() — react Function Reference

commitBeforeMutationEffects_begin() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  512307b3_e8b2_3a7d_0d24_ed564120f990["commitBeforeMutationEffects_begin()"]
  e0fbfbd5_47b0_a489_0b36_bbfad9245544["ReactFiberCommitWork.js"]
  512307b3_e8b2_3a7d_0d24_ed564120f990 -->|defined in| e0fbfbd5_47b0_a489_0b36_bbfad9245544
  4b8572b4_38ff_201d_107a_4c712ded191e["commitBeforeMutationEffects()"]
  4b8572b4_38ff_201d_107a_4c712ded191e -->|calls| 512307b3_e8b2_3a7d_0d24_ed564120f990
  e4b3ff8b_fac9_8119_fde8_1dc24b64f56d["commitBeforeMutationEffectsDeletion()"]
  512307b3_e8b2_3a7d_0d24_ed564120f990 -->|calls| e4b3ff8b_fac9_8119_fde8_1dc24b64f56d
  2fad92d8_0639_0885_b7d6_449cdf46d1c2["trackEnterViewTransitions()"]
  512307b3_e8b2_3a7d_0d24_ed564120f990 -->|calls| 2fad92d8_0639_0885_b7d6_449cdf46d1c2
  68273476_fee5_f7ba_e142_f9c1d94ed124["commitBeforeMutationEffects_complete()"]
  512307b3_e8b2_3a7d_0d24_ed564120f990 -->|calls| 68273476_fee5_f7ba_e142_f9c1d94ed124
  style 512307b3_e8b2_3a7d_0d24_ed564120f990 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberCommitWork.js lines 365–455

function commitBeforeMutationEffects_begin(isViewTransitionEligible: boolean) {
  // If this commit is eligible for a View Transition we look into all mutated subtrees.
  // TODO: We could optimize this by marking these with the Snapshot subtree flag in the render phase.
  const subtreeMask = isViewTransitionEligible
    ? BeforeAndAfterMutationTransitionMask
    : BeforeMutationMask;
  while (nextEffect !== null) {
    const fiber = nextEffect;

    // This phase is only used for beforeActiveInstanceBlur.
    // Let's skip the whole loop if it's off.
    if (enableCreateEventHandleAPI || isViewTransitionEligible) {
      // TODO: Should wrap this in flags check, too, as optimization
      const deletions = fiber.deletions;
      if (deletions !== null) {
        for (let i = 0; i < deletions.length; i++) {
          const deletion = deletions[i];
          commitBeforeMutationEffectsDeletion(
            deletion,
            isViewTransitionEligible,
          );
        }
      }
    }

    if (
      enableViewTransition &&
      fiber.alternate === null &&
      (fiber.flags & Placement) !== NoFlags
    ) {
      // Skip before mutation effects of the children because we don't want
      // to trigger updates of any nested view transitions and we shouldn't
      // have any other before mutation effects since snapshot effects are
      // only applied to updates. TODO: Model this using only flags.
      if (isViewTransitionEligible) {
        trackEnterViewTransitions(fiber);
      }
      commitBeforeMutationEffects_complete(isViewTransitionEligible);
      continue;
    }

    // TODO: This should really unify with the switch in commitBeforeMutationEffectsOnFiber recursively.
    if (enableViewTransition && fiber.tag === OffscreenComponent) {
      const isModernRoot =
        disableLegacyMode || (fiber.mode & ConcurrentMode) !== NoMode;
      if (isModernRoot) {
        const current = fiber.alternate;
        const isHidden = fiber.memoizedState !== null;
        if (isHidden) {
          if (
            current !== null &&
            current.memoizedState === null &&
            isViewTransitionEligible
          ) {
            // Was previously mounted as visible but is now hidden.
            commitExitViewTransitions(current);
          }
          // Skip before mutation effects of the children because they're hidden.
          commitBeforeMutationEffects_complete(isViewTransitionEligible);
          continue;
        } else if (current !== null && current.memoizedState !== null) {
          // Was previously mounted as hidden but is now visible.
          // Skip before mutation effects of the children because we don't want
          // to trigger updates of any nested view transitions and we shouldn't
          // have any other before mutation effects since snapshot effects are
          // only applied to updates. TODO: Model this using only flags.
          if (isViewTransitionEligible) {
            trackEnterViewTransitions(fiber);
          }
          commitBeforeMutationEffects_complete(isViewTransitionEligible);
          continue;
        }
      }
    }

    const child = fiber.child;
    if ((fiber.subtreeFlags & subtreeMask) !== NoFlags && child !== null) {
      child.return = fiber;
      nextEffect = child;
    } else {
      if (isViewTransitionEligible) {

Domain

Subdomains

Frequently Asked Questions

What does commitBeforeMutationEffects_begin() do?
commitBeforeMutationEffects_begin() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberCommitWork.js.
Where is commitBeforeMutationEffects_begin() defined?
commitBeforeMutationEffects_begin() is defined in packages/react-reconciler/src/ReactFiberCommitWork.js at line 365.
What does commitBeforeMutationEffects_begin() call?
commitBeforeMutationEffects_begin() calls 3 function(s): commitBeforeMutationEffectsDeletion, commitBeforeMutationEffects_complete, trackEnterViewTransitions.
What calls commitBeforeMutationEffects_begin()?
commitBeforeMutationEffects_begin() is called by 1 function(s): commitBeforeMutationEffects.

Analyze Your Own Codebase

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

Try Supermodel Free