ReactFiberDuplicateViewTransitions.js — react Source File
Architecture documentation for ReactFiberDuplicateViewTransitions.js, a javascript file in the react codebase. 3 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 5239264d_5f7a_afd8_70d1_f52aaabff11f["ReactFiberDuplicateViewTransitions.js"] 6b9f5caa_fb13_3d3c_2f60_ad3c4f58371f["ReactInternalTypes.js"] 5239264d_5f7a_afd8_70d1_f52aaabff11f --> 6b9f5caa_fb13_3d3c_2f60_ad3c4f58371f c115f947_44f7_8d77_0323_1e260644c151["ReactCurrentFiber.js"] 5239264d_5f7a_afd8_70d1_f52aaabff11f --> c115f947_44f7_8d77_0323_1e260644c151 d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"] 5239264d_5f7a_afd8_70d1_f52aaabff11f --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07 e0fbfbd5_47b0_a489_0b36_bbfad9245544["ReactFiberCommitWork.js"] e0fbfbd5_47b0_a489_0b36_bbfad9245544 --> 5239264d_5f7a_afd8_70d1_f52aaabff11f style 5239264d_5f7a_afd8_70d1_f52aaabff11f 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 {Fiber} from './ReactInternalTypes';
import type {ViewTransitionProps} from 'shared/ReactTypes';
import {runWithFiberInDEV} from './ReactCurrentFiber';
// Use in DEV to track mounted named ViewTransitions. This is used to warn for
// duplicate names. This should technically be tracked per Document because you could
// have two different documents that can have separate namespaces, but to keep things
// simple we just use a global Map. Technically it should also include any manually
// assigned view-transition-name outside React too.
const mountedNamedViewTransitions: Map<string, Fiber> = __DEV__
? new Map()
: (null: any);
const didWarnAboutName: {[string]: boolean} = __DEV__ ? {} : (null: any);
export function trackNamedViewTransition(fiber: Fiber): void {
if (__DEV__) {
const name = (fiber.memoizedProps: ViewTransitionProps).name;
if (name != null && name !== 'auto') {
const existing = mountedNamedViewTransitions.get(name);
if (existing !== undefined) {
if (existing !== fiber && existing !== fiber.alternate) {
if (!didWarnAboutName[name]) {
didWarnAboutName[name] = true;
const stringifiedName = JSON.stringify(name);
runWithFiberInDEV(fiber, () => {
console.error(
'There are two <ViewTransition name=%s> components with the same name mounted ' +
'at the same time. This is not supported and will cause View Transitions ' +
'to error. Try to use a more unique name e.g. by using a namespace prefix ' +
'and adding the id of an item to the name.',
stringifiedName,
);
});
runWithFiberInDEV(existing, () => {
console.error(
'The existing <ViewTransition name=%s> duplicate has this stack trace.',
stringifiedName,
);
});
}
}
} else {
mountedNamedViewTransitions.set(name, fiber);
}
}
}
}
export function untrackNamedViewTransition(fiber: Fiber): void {
if (__DEV__) {
const name = (fiber.memoizedProps: ViewTransitionProps).name;
if (name != null && name !== 'auto') {
const existing = mountedNamedViewTransitions.get(name);
if (
existing !== undefined &&
(existing === fiber || existing === fiber.alternate)
) {
mountedNamedViewTransitions.delete(name);
}
}
}
}
Domain
Subdomains
Dependencies
Source
Frequently Asked Questions
What does ReactFiberDuplicateViewTransitions.js do?
ReactFiberDuplicateViewTransitions.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 ReactFiberDuplicateViewTransitions.js?
ReactFiberDuplicateViewTransitions.js defines 2 function(s): trackNamedViewTransition, untrackNamedViewTransition.
What does ReactFiberDuplicateViewTransitions.js depend on?
ReactFiberDuplicateViewTransitions.js imports 3 module(s): ReactCurrentFiber.js, ReactInternalTypes.js, ReactTypes.
What files import ReactFiberDuplicateViewTransitions.js?
ReactFiberDuplicateViewTransitions.js is imported by 1 file(s): ReactFiberCommitWork.js.
Where is ReactFiberDuplicateViewTransitions.js in the architecture?
ReactFiberDuplicateViewTransitions.js is located at packages/react-reconciler/src/ReactFiberDuplicateViewTransitions.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