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:
Brian Vaughn
2020-05-29 14:34:43 -07:00
committed by GitHub
parent 89edb0eae3
commit 2efe63d99c
19 changed files with 280 additions and 78 deletions

View File

@@ -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,