Home / File/ console.js — react Source File

console.js — react Source File

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

Entity Profile

Dependency Diagram

graph LR
  9cd4bdd2_7005_217e_1e91_ae5eaff3d831["console.js"]
  30d76895_4832_9ca3_9e81_e0cdf028c09c["index.js"]
  30d76895_4832_9ca3_9e81_e0cdf028c09c --> 9cd4bdd2_7005_217e_1e91_ae5eaff3d831
  style 9cd4bdd2_7005_217e_1e91_ae5eaff3d831 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
 */

function ignoreStrings(
  methodName: string,
  stringsToIgnore: Array<string>,
): void {
  // $FlowFixMe[prop-missing] index access only allowed for objects with index keys
  console[methodName] = (...args: $ReadOnlyArray<mixed>) => {
    const maybeString = args[0];
    if (typeof maybeString === 'string') {
      for (let i = 0; i < stringsToIgnore.length; i++) {
        if (maybeString.startsWith(stringsToIgnore[i])) {
          return;
        }
      }
    }

    // HACKY In the test harness, DevTools overrides the parent window's console.
    // Our test app code uses the iframe's console though.
    // To simulate a more accurate end-to-end environment,
    // the shell's console patching should pass through to the parent override methods.
    window.parent.console[methodName](...args);
  };
}

export function ignoreErrors(errorsToIgnore: Array<string>): void {
  ignoreStrings('error', errorsToIgnore);
}

export function ignoreWarnings(warningsToIgnore: Array<string>): void {
  ignoreStrings('warn', warningsToIgnore);
}

export function ignoreLogs(logsToIgnore: Array<string>): void {
  ignoreStrings('log', logsToIgnore);
}

Domain

Frequently Asked Questions

What does console.js do?
console.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What files import console.js?
console.js is imported by 1 file(s): index.js.
Where is console.js in the architecture?
console.js is located at packages/react-devtools-shell/src/app/console.js (domain: BabelCompiler, directory: packages/react-devtools-shell/src/app).

Analyze Your Own Codebase

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

Try Supermodel Free