MCPcopy Index your code
hub / github.com/react/react / overrideMethod

Function overrideMethod

packages/react-devtools-shared/src/hook.js:356–382  ·  view source on GitHub ↗
(
        ...args: any[]
      )

Source from the content-addressed store, hash-verified

354 for (const method of consoleMethodsToOverrideForStrictMode) {
355 const originalMethod = targetConsole[method];
356 const overrideMethod: (...args: Array<any>) => void = (
357 ...args: any[]
358 ) => {
359 const settings = hook.settings;
360 // Something unexpected happened, fallback to just printing the console message.
361 if (settings == null) {
362 originalMethod(...args);
363 return;
364 }
365
366 if (settings.hideConsoleLogsInStrictMode) {
367 return;
368 }
369
370 // Dim the text color of the double logs if we're not hiding them.
371 // Firefox doesn't support ANSI escape sequences
372 if (__IS_FIREFOX__) {
373 originalMethod(
374 ...formatWithStyles(args, FIREFOX_CONSOLE_DIMMING_COLOR),
375 );
376 } else {
377 originalMethod(
378 ANSI_STYLE_DIMMING_TEMPLATE,
379 ...formatConsoleArguments(...args),
380 );
381 }
382 };
383
384 targetConsole[method] = overrideMethod;
385 unpatchConsoleCallbacks.push(() => {

Callers

nothing calls this directly

Calls 8

formatWithStylesFunction · 0.85
formatConsoleArgumentsFunction · 0.85
isStringComponentStackFunction · 0.85
areStackTracesEqualFunction · 0.85
valuesMethod · 0.65
pushMethod · 0.65
onErrorOrWarningFunction · 0.50
getComponentStackFunction · 0.50

Tested by

no test coverage detected