Skip to content

Commit

Permalink
Expose DEV-mode warnings in devtools UI (#20463)
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Vaughn <bvaughn@fb.com>
  • Loading branch information
eps1lon and Brian Vaughn authored Dec 22, 2020
1 parent 6cbb939 commit 09a2c36
Show file tree
Hide file tree
Showing 50 changed files with 4,613 additions and 1,794 deletions.
4 changes: 4 additions & 0 deletions packages/react-devtools-core/src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
getAppendComponentStack,
getBreakOnConsoleErrors,
getSavedComponentFilters,
getShowInlineWarningsAndErrors,
} from 'react-devtools-shared/src/utils';
import {Server} from 'ws';
import {join} from 'path';
Expand Down Expand Up @@ -303,6 +304,9 @@ function startServer(
)};
window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = ${JSON.stringify(
getSavedComponentFilters(),
)};
window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = ${JSON.stringify(
getShowInlineWarningsAndErrors(),
)};`;

response.end(
Expand Down
13 changes: 7 additions & 6 deletions packages/react-devtools-extensions/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getAppendComponentStack,
getBreakOnConsoleErrors,
getSavedComponentFilters,
getShowInlineWarningsAndErrors,
} from 'react-devtools-shared/src/utils';
import {
localStorageGetItem,
Expand All @@ -29,18 +30,18 @@ let panelCreated = false;
// because they are stored in localStorage within the context of the extension.
// Instead it relies on the extension to pass filters through.
function syncSavedPreferences() {
const appendComponentStack = getAppendComponentStack();
const breakOnConsoleErrors = getBreakOnConsoleErrors();
const componentFilters = getSavedComponentFilters();
chrome.devtools.inspectedWindow.eval(
`window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ = ${JSON.stringify(
appendComponentStack,
getAppendComponentStack(),
)};
window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ = ${JSON.stringify(
breakOnConsoleErrors,
getBreakOnConsoleErrors(),
)};
window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = ${JSON.stringify(
componentFilters,
getSavedComponentFilters(),
)};
window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = ${JSON.stringify(
getShowInlineWarningsAndErrors(),
)};`,
);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/react-devtools-inline/src/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ function startActivation(contentWindow: window) {
appendComponentStack,
breakOnConsoleErrors,
componentFilters,
showInlineWarningsAndErrors,
} = data;

contentWindow.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ = appendComponentStack;
contentWindow.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ = breakOnConsoleErrors;
contentWindow.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = componentFilters;
contentWindow.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = showInlineWarningsAndErrors;

// TRICKY
// The backend entry point may be required in the context of an iframe or the parent window.
Expand All @@ -40,6 +42,7 @@ function startActivation(contentWindow: window) {
window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ = appendComponentStack;
window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ = breakOnConsoleErrors;
window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = componentFilters;
window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = showInlineWarningsAndErrors;
}

finishActivation(contentWindow);
Expand Down
2 changes: 2 additions & 0 deletions packages/react-devtools-inline/src/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getAppendComponentStack,
getBreakOnConsoleErrors,
getSavedComponentFilters,
getShowInlineWarningsAndErrors,
} from 'react-devtools-shared/src/utils';
import {
MESSAGE_TYPE_GET_SAVED_PREFERENCES,
Expand Down Expand Up @@ -41,6 +42,7 @@ export function initialize(
appendComponentStack: getAppendComponentStack(),
breakOnConsoleErrors: getBreakOnConsoleErrors(),
componentFilters: getSavedComponentFilters(),
showInlineWarningsAndErrors: getShowInlineWarningsAndErrors(),
},
'*',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ Array [
Object {
"displayName": "Grandparent",
"hocDisplayNames": null,
"id": 7,
"id": 2,
"type": 5,
},
Object {
"displayName": "Parent",
"hocDisplayNames": null,
"id": 9,
"id": 3,
"type": 5,
},
Object {
"displayName": "Child",
"hocDisplayNames": null,
"id": 8,
"id": 4,
"type": 5,
},
]
Expand Down Expand Up @@ -115,7 +115,7 @@ Array [
Object {
"displayName": "Grandparent",
"hocDisplayNames": null,
"id": 5,
"id": 2,
"type": 5,
},
]
Expand Down

This file was deleted.

Loading

0 comments on commit 09a2c36

Please sign in to comment.