getOwnerStackByFiberInDev() — react Function Reference
Architecture documentation for the getOwnerStackByFiberInDev() function in DevToolsFiberComponentStack.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 4107a6e9_e64c_c0f0_6fdd_b5fee354334b["getOwnerStackByFiberInDev()"] 2bbfa631_5780_6883_1746_b7c42df10b5d["DevToolsFiberComponentStack.js"] 4107a6e9_e64c_c0f0_6fdd_b5fee354334b -->|defined in| 2bbfa631_5780_6883_1746_b7c42df10b5d b79d7933_7e8b_53e4_29f2_b6516a60dac8["describeBuiltInComponentFrame()"] 4107a6e9_e64c_c0f0_6fdd_b5fee354334b -->|calls| b79d7933_7e8b_53e4_29f2_b6516a60dac8 a8f4c31f_f504_975a_5ac7_bb83d1cf4164["formatOwnerStack()"] 4107a6e9_e64c_c0f0_6fdd_b5fee354334b -->|calls| a8f4c31f_f504_975a_5ac7_bb83d1cf4164 style 4107a6e9_e64c_c0f0_6fdd_b5fee354334b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-shared/src/backend/fiber/DevToolsFiberComponentStack.js lines 147–232
export function getOwnerStackByFiberInDev(
workTagMap: WorkTagMap,
workInProgress: Fiber,
currentDispatcherRef: CurrentDispatcherRef,
): string {
const {
HostHoistable,
HostSingleton,
HostText,
HostComponent,
SuspenseComponent,
SuspenseListComponent,
ViewTransitionComponent,
ActivityComponent,
} = workTagMap;
try {
let info = '';
if (workInProgress.tag === HostText) {
// Text nodes never have an owner/stack because they're not created through JSX.
// We use the parent since text nodes are always created through a host parent.
workInProgress = (workInProgress.return: any);
}
// The owner stack of the current fiber 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, for built-ins there is no such
// named stack frame and it would be ignored as being internal anyway. Therefore we add
// add one extra frame just to describe the "current" built-in component by name.
switch (workInProgress.tag) {
case HostHoistable:
case HostSingleton:
case HostComponent:
info += describeBuiltInComponentFrame(workInProgress.type);
break;
case SuspenseComponent:
info += describeBuiltInComponentFrame('Suspense');
break;
case SuspenseListComponent:
info += describeBuiltInComponentFrame('SuspenseList');
break;
case ViewTransitionComponent:
info += describeBuiltInComponentFrame('ViewTransition');
break;
case ActivityComponent:
info += describeBuiltInComponentFrame('Activity');
break;
}
let owner: void | null | Fiber | ReactComponentInfo = workInProgress;
while (owner) {
if (typeof owner.tag === 'number') {
const fiber: Fiber = (owner: any);
owner = fiber._debugOwner;
let debugStack: void | null | string | Error = fiber._debugStack;
// If we don't actually print the stack if there is no owner of this JSX element.
// In a real app it's typically not useful since the root app is always controlled
// by the framework. These also tend to have noisy stacks because they're not rooted
// in a React render but in some imperative bootstrapping code. It could be useful
// if the element was created in module scope. E.g. hoisted. We could add a a single
// stack frame for context for example but it doesn't say much if that's a wrapper.
if (owner && debugStack) {
if (typeof debugStack !== 'string') {
debugStack = formatOwnerStack(debugStack);
}
if (debugStack !== '') {
info += '\n' + debugStack;
}
}
} else if (owner.debugStack != null) {
// Server Component
const ownerStack: Error = owner.debugStack;
owner = owner.owner;
if (owner && ownerStack) {
info += '\n' + formatOwnerStack(ownerStack);
}
} else {
break;
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does getOwnerStackByFiberInDev() do?
getOwnerStackByFiberInDev() is a function in the react codebase, defined in packages/react-devtools-shared/src/backend/fiber/DevToolsFiberComponentStack.js.
Where is getOwnerStackByFiberInDev() defined?
getOwnerStackByFiberInDev() is defined in packages/react-devtools-shared/src/backend/fiber/DevToolsFiberComponentStack.js at line 147.
What does getOwnerStackByFiberInDev() call?
getOwnerStackByFiberInDev() calls 2 function(s): describeBuiltInComponentFrame, formatOwnerStack.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free