MCPcopy
hub / github.com/facebook/react / ignoreStrings

Function ignoreStrings

packages/react-devtools-shell/src/app/console.js:10–31  ·  view source on GitHub ↗

* 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

(
  methodName: string,
  stringsToIgnore: Array<string>,
)

Source from the content-addressed store, hash-verified

8 */
9
10function ignoreStrings(
11 methodName: string,
12 stringsToIgnore: Array<string>,
13): void {
14 // $FlowFixMe[prop-missing] index access only allowed for objects with index keys
15 console[methodName] = (...args: $ReadOnlyArray<mixed>) => {
16 const maybeString = args[0];
17 if (typeof maybeString === 'string') {
18 for (let i = 0; i < stringsToIgnore.length; i++) {
19 if (maybeString.startsWith(stringsToIgnore[i])) {
20 return;
21 }
22 }
23 }
24
25 // HACKY In the test harness, DevTools overrides the parent window's console.
26 // Our test app code uses the iframe's console though.
27 // To simulate a more accurate end-to-end environment,
28 // the shell's console patching should pass through to the parent override methods.
29 window.parent.console[methodName](...args);
30 };
31}
32
33export function ignoreErrors(errorsToIgnore: Array<string>): void {
34 ignoreStrings('error', errorsToIgnore);

Callers 3

ignoreErrorsFunction · 0.85
ignoreWarningsFunction · 0.85
ignoreLogsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected