Skip to content

Commit cb14168

Browse files
authored
Remove unnecessary throw catch (#19044)
This was originally added so you could use "break on caught exceptions" but that feature is pretty useless these days since it's used for feature detection and Suspense. The better pattern is to use the stack trace, jump to source and set a break point here. Since DevTools injects its own console.error, we could inject a "debugger" statement in there. Conditionally. E.g. React DevTools could have a flag to toggle "break on warnings".
1 parent c03b866 commit cb14168

1 file changed

Lines changed: 0 additions & 10 deletions

File tree

packages/shared/consoleWithStackDev.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,5 @@ function printWarning(level, format, args) {
4343
// breaks IE9: https://github.com/facebook/react/issues/13610
4444
// eslint-disable-next-line react-internal/no-production-logging
4545
Function.prototype.apply.call(console[level], console, argsWithFormat);
46-
47-
try {
48-
// --- Welcome to debugging React ---
49-
// This error was thrown as a convenience so that you can use this stack
50-
// to find the callsite that caused this warning to fire.
51-
let argIndex = 0;
52-
const message =
53-
'Warning: ' + format.replace(/%s/g, () => args[argIndex++]);
54-
throw new Error(message);
55-
} catch (x) {}
5646
}
5747
}

0 commit comments

Comments
 (0)