mirror of
https://github.com/facebook/react.git
synced 2026-02-26 18:58:05 +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:
20
packages/react-devtools-shared/src/utils.js
vendored
20
packages/react-devtools-shared/src/utils.js
vendored
@@ -31,6 +31,7 @@ import {
|
||||
import {ElementTypeRoot} from 'react-devtools-shared/src/types';
|
||||
import {
|
||||
LOCAL_STORAGE_FILTER_PREFERENCES_KEY,
|
||||
LOCAL_STORAGE_SHOULD_BREAK_ON_CONSOLE_ERRORS,
|
||||
LOCAL_STORAGE_SHOULD_PATCH_CONSOLE_KEY,
|
||||
} from './constants';
|
||||
import {ComponentFilterElementType, ElementTypeHostComponent} from './types';
|
||||
@@ -248,6 +249,25 @@ export function setAppendComponentStack(value: boolean): void {
|
||||
);
|
||||
}
|
||||
|
||||
export function getBreakOnConsoleErrors(): boolean {
|
||||
try {
|
||||
const raw = localStorageGetItem(
|
||||
LOCAL_STORAGE_SHOULD_BREAK_ON_CONSOLE_ERRORS,
|
||||
);
|
||||
if (raw != null) {
|
||||
return JSON.parse(raw);
|
||||
}
|
||||
} catch (error) {}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function setBreakOnConsoleErrors(value: boolean): void {
|
||||
localStorageSetItem(
|
||||
LOCAL_STORAGE_SHOULD_BREAK_ON_CONSOLE_ERRORS,
|
||||
JSON.stringify(value),
|
||||
);
|
||||
}
|
||||
|
||||
export function separateDisplayNameAndHOCs(
|
||||
displayName: string | null,
|
||||
type: ElementType,
|
||||
|
||||
Reference in New Issue
Block a user