ReactComponentInfoStack.js — react Source File
Architecture documentation for ReactComponentInfoStack.js, a javascript file in the react codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR fc2707c9_28bf_6212_3c95_549c8c89a1df["ReactComponentInfoStack.js"] d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"] fc2707c9_28bf_6212_3c95_549c8c89a1df --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07 ee0b3c9c_9a89_ddf3_7d8a_b6e3d5961d75["ReactComponentStackFrame"] fc2707c9_28bf_6212_3c95_549c8c89a1df --> ee0b3c9c_9a89_ddf3_7d8a_b6e3d5961d75 f3c177af_2c49_dd70_e1c6_29ae3280aad1["ReactOwnerStackFrames"] fc2707c9_28bf_6212_3c95_549c8c89a1df --> f3c177af_2c49_dd70_e1c6_29ae3280aad1 style fc2707c9_28bf_6212_3c95_549c8c89a1df 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 {ReactComponentInfo} from 'shared/ReactTypes';
import {describeBuiltInComponentFrame} from 'shared/ReactComponentStackFrame';
import {formatOwnerStack} from 'shared/ReactOwnerStackFrames';
export function getOwnerStackByComponentInfoInDev(
componentInfo: ReactComponentInfo,
): string {
if (!__DEV__) {
return '';
}
try {
let info = '';
// The owner stack of the current component will be where it was created, i.e. inside its owner.
// There's no actual name of the currently executing component. Instead, that is available
// on the regular stack that's currently executing. However, if there is no owner at all, then
// there's no stack frame so we add the name of the root component to the stack to know which
// component is currently executing.
if (!componentInfo.owner && typeof componentInfo.name === 'string') {
return describeBuiltInComponentFrame(componentInfo.name);
}
let owner: void | null | ReactComponentInfo = componentInfo;
while (owner) {
const ownerStack: ?Error = owner.debugStack;
if (ownerStack != null) {
// Server Component
owner = owner.owner;
if (owner) {
// TODO: Should we stash this somewhere for caching purposes?
info += '\n' + formatOwnerStack(ownerStack);
}
} else {
break;
}
}
return info;
} catch (x) {
return '\nError generating stack: ' + x.message + '\n' + x.stack;
}
}
Domain
Subdomains
Functions
Dependencies
- ReactComponentStackFrame
- ReactOwnerStackFrames
- ReactTypes
Source
Frequently Asked Questions
What does ReactComponentInfoStack.js do?
ReactComponentInfoStack.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in ReactComponentInfoStack.js?
ReactComponentInfoStack.js defines 1 function(s): getOwnerStackByComponentInfoInDev.
What does ReactComponentInfoStack.js depend on?
ReactComponentInfoStack.js imports 3 module(s): ReactComponentStackFrame, ReactOwnerStackFrames, ReactTypes.
Where is ReactComponentInfoStack.js in the architecture?
ReactComponentInfoStack.js is located at packages/shared/ReactComponentInfoStack.js (domain: BabelCompiler, subdomain: Optimization, directory: packages/shared).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free