Patch console to append component stacks (#348)

* Patch console.warn and console.error to auto-append owners-only component stacks.

This setting is enabled by default and will work for React Native even if no front-end DevTools shell is being used. The setting can be disabled via a new, persisted user preference though.
This commit is contained in:
Brian Vaughn
2019-07-17 11:12:39 -07:00
committed by GitHub
parent 0f2fb5badf
commit cb3fb42129
24 changed files with 1085 additions and 257 deletions
+2 -1
View File
@@ -8,7 +8,7 @@ import { installHook } from 'src/hook';
import { initDevTools } from 'src/devtools';
import Store from 'src/devtools/store';
import DevTools from 'src/devtools/views/DevTools';
import { getSavedComponentFilters } from 'src/utils';
import { getSavedComponentFilters, getAppendComponentStack } from 'src/utils';
const iframe = ((document.getElementById('target'): any): HTMLIFrameElement);
@@ -18,6 +18,7 @@ const { contentDocument, contentWindow } = iframe;
// because they are stored in localStorage within the context of the extension.
// Instead it relies on the extension to pass filters through.
contentWindow.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = getSavedComponentFilters();
contentWindow.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ = getAppendComponentStack();
installHook(contentWindow);