Home / Function/ bindToConsole() — react Function Reference

bindToConsole() — react Function Reference

Architecture documentation for the bindToConsole() function in ReactClientConsoleConfigPlain.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  da4366be_97e4_ec62_8644_731cc7c1a6e1["bindToConsole()"]
  03c01cc0_d9f4_6450_2f42_8cce4f1274fd["ReactClientConsoleConfigPlain.js"]
  da4366be_97e4_ec62_8644_731cc7c1a6e1 -->|defined in| 03c01cc0_d9f4_6450_2f42_8cce4f1274fd
  style da4366be_97e4_ec62_8644_731cc7c1a6e1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-client/src/ReactClientConsoleConfigPlain.js lines 16–54

export function bindToConsole(
  methodName: string,
  args: Array<any>,
  badgeName: string,
): () => any {
  let offset = 0;
  switch (methodName) {
    case 'dir':
    case 'dirxml':
    case 'groupEnd':
    case 'table': {
      // These methods cannot be colorized because they don't take a formatting string.
      // $FlowFixMe
      return bind.apply(console[methodName], [console].concat(args)); // eslint-disable-line react-internal/no-production-logging
    }
    case 'assert': {
      // assert takes formatting options as the second argument.
      offset = 1;
    }
  }

  const newArgs = args.slice(0);
  if (typeof newArgs[offset] === 'string') {
    newArgs.splice(
      offset,
      1,
      badgeFormat + ' ' + newArgs[offset],
      pad + badgeName + pad,
    );
  } else {
    newArgs.splice(offset, 0, badgeFormat, pad + badgeName + pad);
  }

  // The "this" binding in the "bind";
  newArgs.unshift(console);

  // $FlowFixMe
  return bind.apply(console[methodName], newArgs); // eslint-disable-line react-internal/no-production-logging
}

Domain

Subdomains

Frequently Asked Questions

What does bindToConsole() do?
bindToConsole() is a function in the react codebase, defined in packages/react-client/src/ReactClientConsoleConfigPlain.js.
Where is bindToConsole() defined?
bindToConsole() is defined in packages/react-client/src/ReactClientConsoleConfigPlain.js at line 16.

Analyze Your Own Codebase

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

Try Supermodel Free