mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
DevTools: Add break-on-warn feature (#19048)
This commit adds a new tab to the Settings modal: Debugging This new tab has the append component stacks feature and a new one: break on warn This new feature adds a debugger statement into the console override
This commit is contained in:
+10
-2
@@ -174,6 +174,11 @@ export function installHook(target: any): DevToolsHook | null {
|
||||
// Don't patch in test environments because we don't want to interfere with Jest's own console overrides.
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
try {
|
||||
const appendComponentStack =
|
||||
window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ !== false;
|
||||
const breakOnConsoleErrors =
|
||||
window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ === true;
|
||||
|
||||
// The installHook() function is injected by being stringified in the browser,
|
||||
// so imports outside of this function do not get included.
|
||||
//
|
||||
@@ -181,9 +186,12 @@ export function installHook(target: any): DevToolsHook | null {
|
||||
// but Webpack wraps imports with an object (e.g. _backend_console__WEBPACK_IMPORTED_MODULE_0__)
|
||||
// and the object itself will be undefined as well for the reasons mentioned above,
|
||||
// so we use try/catch instead.
|
||||
if (window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ !== false) {
|
||||
if (appendComponentStack || breakOnConsoleErrors) {
|
||||
registerRendererWithConsole(renderer);
|
||||
patchConsole();
|
||||
patchConsole({
|
||||
appendComponentStack,
|
||||
breakOnConsoleErrors,
|
||||
});
|
||||
}
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user