Home / File/ DevToolsOwnerStack.js — react Source File

DevToolsOwnerStack.js — react Source File

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

File javascript BabelCompiler Validation 4 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  ca4a7497_d233_4d3d_e832_e2f96306e9ae["DevToolsOwnerStack.js"]
  2bbfa631_5780_6883_1746_b7c42df10b5d["DevToolsFiberComponentStack.js"]
  2bbfa631_5780_6883_1746_b7c42df10b5d --> ca4a7497_d233_4d3d_e832_e2f96306e9ae
  7dc1582f_e5c4_6fb0_e998_bd2982c8c801["renderer.js"]
  7dc1582f_e5c4_6fb0_e998_bd2982c8c801 --> ca4a7497_d233_4d3d_e832_e2f96306e9ae
  aa545f4b_797f_d455_0d48_d21828047895["DevToolsComponentInfoStack.js"]
  aa545f4b_797f_d455_0d48_d21828047895 --> ca4a7497_d233_4d3d_e832_e2f96306e9ae
  50ab7512_20ae_29b1_e876_3d07fe8f521c["renderer.js"]
  50ab7512_20ae_29b1_e876_3d07fe8f521c --> ca4a7497_d233_4d3d_e832_e2f96306e9ae
  style ca4a7497_d233_4d3d_e832_e2f96306e9ae 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 shared/ReactOwnerStackFrames.

export function formatOwnerStack(error: Error): string {
  const prevPrepareStackTrace = Error.prepareStackTrace;
  // $FlowFixMe[incompatible-type] It does accept undefined.
  Error.prepareStackTrace = undefined;
  let stack = error.stack;
  Error.prepareStackTrace = prevPrepareStackTrace;

  if (stack.startsWith('Error: react-stack-top-frame\n')) {
    // V8's default formatting prefixes with the error message which we
    // don't want/need.
    stack = stack.slice(29);
  }
  let idx = stack.indexOf('\n');
  if (idx !== -1) {
    // Pop the JSX frame.
    stack = stack.slice(idx + 1);
  }
  idx = stack.indexOf('react_stack_bottom_frame');
  if (idx === -1) {
    idx = stack.indexOf('react-stack-bottom-frame');
  }
  if (idx !== -1) {
    idx = stack.lastIndexOf('\n', idx);
  }
  if (idx !== -1) {
    // Cut off everything after the bottom frame since it'll be internals.
    stack = stack.slice(0, idx);
  } else {
    // We didn't find any internal callsite out to user space.
    // This means that this was called outside an owner or the owner is fully internal.
    // To keep things light we exclude the entire trace in this case.
    return '';
  }
  return stack;
}

Domain

Subdomains

Functions

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free