Home / File/ ReactFiberViewTransitionComponent.js — react Source File

ReactFiberViewTransitionComponent.js — react Source File

Architecture documentation for ReactFiberViewTransitionComponent.js, a javascript file in the react codebase. 4 imports, 7 dependents.

File javascript BabelCompiler Validation 4 imports 7 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3["ReactFiberViewTransitionComponent.js"]
  6b9f5caa_fb13_3d3c_2f60_ad3c4f58371f["ReactInternalTypes.js"]
  d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3 --> 6b9f5caa_fb13_3d3c_2f60_ad3c4f58371f
  a6668d1d_397d_7807_719d_fdecf552fa4a["ReactFiberConfig.js"]
  d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3 --> a6668d1d_397d_7807_719d_fdecf552fa4a
  d73e9290_2d2e_5d3f_97dd_84929f205c77["ReactFiberWorkLoop.js"]
  d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3 --> d73e9290_2d2e_5d3f_97dd_84929f205c77
  d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"]
  d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3 --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07
  8a03468f_f6e2_d5a3_fdef_e77ebca449c2["ReactFiber.js"]
  8a03468f_f6e2_d5a3_fdef_e77ebca449c2 --> d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3
  ee850b36_fc0b_9bb2_5b69_58d705aef9a5["ReactFiberApplyGesture.js"]
  ee850b36_fc0b_9bb2_5b69_58d705aef9a5 --> d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3
  0be70812_cc0c_b210_f84f_8e61dd5f831c["ReactFiberBeginWork.js"]
  0be70812_cc0c_b210_f84f_8e61dd5f831c --> d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3
  8f5342bb_933e_6410_b584_cc120047394a["ReactFiberCommitEffects.js"]
  8f5342bb_933e_6410_b584_cc120047394a --> d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3
  08bb6a7c_2c07_1880_07ef_82d9f5cf2d76["ReactFiberCommitViewTransitions.js"]
  08bb6a7c_2c07_1880_07ef_82d9f5cf2d76 --> d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3
  e0fbfbd5_47b0_a489_0b36_bbfad9245544["ReactFiberCommitWork.js"]
  e0fbfbd5_47b0_a489_0b36_bbfad9245544 --> d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3
  d73e9290_2d2e_5d3f_97dd_84929f205c77["ReactFiberWorkLoop.js"]
  d73e9290_2d2e_5d3f_97dd_84929f205c77 --> d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3
  style d8bd6ba1_1cbe_86c2_6f2f_604c53e981b3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import type {ViewTransitionClass, ViewTransitionProps} from 'shared/ReactTypes';
import type {FiberRoot} from './ReactInternalTypes';
import type {ViewTransitionInstance, Instance} from './ReactFiberConfig';

import {
  getCommittingRoot,
  getPendingTransitionTypes,
} from './ReactFiberWorkLoop';

export type ViewTransitionState = {
  autoName: null | string, // the view-transition-name to use when an explicit one is not specified
  paired: null | ViewTransitionState, // a temporary state during the commit phase if we have paired this with another instance
  clones: null | Array<Instance>, // a temporary state during the apply gesture phase if we cloned this boundary
  ref: null | ViewTransitionInstance, // the current ref instance. This can change through the lifetime of the instance.
};

let globalClientIdCounter: number = 0;

export function getViewTransitionName(
  props: ViewTransitionProps,
  instance: ViewTransitionState,
): string {
  if (props.name != null && props.name !== 'auto') {
    return props.name;
  }
  if (instance.autoName !== null) {
    return instance.autoName;
  }

  // We assume we always call this in the commit phase.
  const root = ((getCommittingRoot(): any): FiberRoot);
  const identifierPrefix = root.identifierPrefix;
  const globalClientId = globalClientIdCounter++;
  const name =
    '_' + identifierPrefix + 't_' + globalClientId.toString(32) + '_';
  instance.autoName = name;
  return name;
}

function getClassNameByType(classByType: ?ViewTransitionClass): ?string {
  if (classByType == null || typeof classByType === 'string') {
    return classByType;
  }
  let className: ?string = null;
  const activeTypes = getPendingTransitionTypes();
  if (activeTypes !== null) {
    for (let i = 0; i < activeTypes.length; i++) {
      const match = classByType[activeTypes[i]];
      if (match != null) {
        if (match === 'none') {
          // If anything matches "none" that takes precedence over any other
          // type that also matches.
          return 'none';
        }
        if (className == null) {
          className = match;
        } else {
          className += ' ' + match;
        }
      }
    }
  }
  if (className == null) {
    // We had no other matches. Match the default for this configuration.
    return classByType.default;
  }
  return className;
}

export function getViewTransitionClassName(
  defaultClass: ?ViewTransitionClass,
  eventClass: ?ViewTransitionClass,
): ?string {
  const className: ?string = getClassNameByType(defaultClass);
  const eventClassName: ?string = getClassNameByType(eventClass);
  if (eventClassName == null) {
    return className === 'auto' ? null : className;
  }
  if (eventClassName === 'auto') {
    return null;
  }
  return eventClassName;
}

Domain

Subdomains

Frequently Asked Questions

What does ReactFiberViewTransitionComponent.js do?
ReactFiberViewTransitionComponent.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactFiberViewTransitionComponent.js?
ReactFiberViewTransitionComponent.js defines 3 function(s): getClassNameByType, getViewTransitionClassName, getViewTransitionName.
What does ReactFiberViewTransitionComponent.js depend on?
ReactFiberViewTransitionComponent.js imports 4 module(s): ReactFiberConfig.js, ReactFiberWorkLoop.js, ReactInternalTypes.js, ReactTypes.
What files import ReactFiberViewTransitionComponent.js?
ReactFiberViewTransitionComponent.js is imported by 7 file(s): ReactFiber.js, ReactFiberApplyGesture.js, ReactFiberBeginWork.js, ReactFiberCommitEffects.js, ReactFiberCommitViewTransitions.js, ReactFiberCommitWork.js, ReactFiberWorkLoop.js.
Where is ReactFiberViewTransitionComponent.js in the architecture?
ReactFiberViewTransitionComponent.js is located at packages/react-reconciler/src/ReactFiberViewTransitionComponent.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-reconciler/src).

Analyze Your Own Codebase

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

Try Supermodel Free