Home / File/ DevToolsComponentInfoStack.js — react Source File

DevToolsComponentInfoStack.js — react Source File

Architecture documentation for DevToolsComponentInfoStack.js, a javascript file in the react codebase. 5 imports, 1 dependents.

File javascript BabelCompiler Validation 5 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  aa545f4b_797f_d455_0d48_d21828047895["DevToolsComponentInfoStack.js"]
  c59dc57c_ed0c_b6cd_803d_b7eeab46f99e["DevToolsComponentStackFrame.js"]
  aa545f4b_797f_d455_0d48_d21828047895 --> c59dc57c_ed0c_b6cd_803d_b7eeab46f99e
  b79d7933_7e8b_53e4_29f2_b6516a60dac8["describeBuiltInComponentFrame"]
  aa545f4b_797f_d455_0d48_d21828047895 --> b79d7933_7e8b_53e4_29f2_b6516a60dac8
  ca4a7497_d233_4d3d_e832_e2f96306e9ae["DevToolsOwnerStack.js"]
  aa545f4b_797f_d455_0d48_d21828047895 --> ca4a7497_d233_4d3d_e832_e2f96306e9ae
  a8f4c31f_f504_975a_5ac7_bb83d1cf4164["formatOwnerStack"]
  aa545f4b_797f_d455_0d48_d21828047895 --> a8f4c31f_f504_975a_5ac7_bb83d1cf4164
  d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"]
  aa545f4b_797f_d455_0d48_d21828047895 --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07
  50ab7512_20ae_29b1_e876_3d07fe8f521c["renderer.js"]
  50ab7512_20ae_29b1_e876_3d07fe8f521c --> aa545f4b_797f_d455_0d48_d21828047895
  style aa545f4b_797f_d455_0d48_d21828047895 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
 */

// This is a DevTools fork of ReactComponentInfoStack.
// This fork enables DevTools to use the same "native" component stack format,
// while still maintaining support for multiple renderer versions
// (which use different values for ReactTypeOfWork).

import type {ReactComponentInfo} from 'shared/ReactTypes';

import {describeBuiltInComponentFrame} from '../shared/DevToolsComponentStackFrame';

import {formatOwnerStack} from '../shared/DevToolsOwnerStack';

export function getOwnerStackByComponentInfoInDev(
  componentInfo: ReactComponentInfo,
): string {
  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

Frequently Asked Questions

What does DevToolsComponentInfoStack.js do?
DevToolsComponentInfoStack.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 DevToolsComponentInfoStack.js?
DevToolsComponentInfoStack.js defines 1 function(s): getOwnerStackByComponentInfoInDev.
What does DevToolsComponentInfoStack.js depend on?
DevToolsComponentInfoStack.js imports 5 module(s): DevToolsComponentStackFrame.js, DevToolsOwnerStack.js, ReactTypes, describeBuiltInComponentFrame, formatOwnerStack.
What files import DevToolsComponentInfoStack.js?
DevToolsComponentInfoStack.js is imported by 1 file(s): renderer.js.
Where is DevToolsComponentInfoStack.js in the architecture?
DevToolsComponentInfoStack.js is located at packages/react-devtools-shared/src/backend/flight/DevToolsComponentInfoStack.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/backend/flight).

Analyze Your Own Codebase

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

Try Supermodel Free