Home / Function/ disableLogs() — react Function Reference

disableLogs() — react Function Reference

Architecture documentation for the disableLogs() function in ConsolePatchingDev.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  92b3b40c_43c3_035f_941b_af66f96bbf6e["disableLogs()"]
  12e674e2_5612_a3e0_5427_15a1ac66df53["ConsolePatchingDev.js"]
  92b3b40c_43c3_035f_941b_af66f96bbf6e -->|defined in| 12e674e2_5612_a3e0_5427_15a1ac66df53
  style 92b3b40c_43c3_035f_941b_af66f96bbf6e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shared/ConsolePatchingDev.js lines 27–58

export function disableLogs(): void {
  if (__DEV__) {
    if (disabledDepth === 0) {
      /* eslint-disable react-internal/no-production-logging */
      prevLog = console.log;
      prevInfo = console.info;
      prevWarn = console.warn;
      prevError = console.error;
      prevGroup = console.group;
      prevGroupCollapsed = console.groupCollapsed;
      prevGroupEnd = console.groupEnd;
      // https://github.com/facebook/react/issues/19099
      const props = {
        configurable: true,
        enumerable: true,
        value: disabledLog,
        writable: true,
      };
      // $FlowFixMe[cannot-write] Flow thinks console is immutable.
      Object.defineProperties(console, {
        info: props,
        log: props,
        warn: props,
        error: props,
        group: props,
        groupCollapsed: props,
        groupEnd: props,
      });
    }
    disabledDepth++;
  }
}

Domain

Subdomains

Frequently Asked Questions

What does disableLogs() do?
disableLogs() is a function in the react codebase, defined in packages/shared/ConsolePatchingDev.js.
Where is disableLogs() defined?
disableLogs() is defined in packages/shared/ConsolePatchingDev.js at line 27.

Analyze Your Own Codebase

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

Try Supermodel Free