React Native fixes for new inline errors feature (#20502)
Brian Vaughn committed
Dec 22, 2020 at 10:58 UTC
50393dc3a0c59cfefd349d31992256efd6f8c261
4 files changed
+9
-11
packages/react-devtools-shared/src/__tests__/inspectedElementContext-test.js
+2
-1
@@ -2014,7 +2014,8 @@ describe('InspectedElementContext', () => {
2014
Object {
2015
"errors": Array [
2016
Array [
2017
- "Warning: Each child in a list should have a unique \\"key\\" prop. See https://reactjs.org/link/warning-keys for more information.",
2017
+ "Warning: Each child in a list should have a unique \\"key\\" prop. See https://reactjs.org/link/warning-keys for more information.
2018
+ at Example",
2019
1,
2020
],
2021
],
packages/react-devtools-shared/src/backend/console.js
+5
-8
@@ -140,12 +140,12 @@ export function patch({
140
targetConsole[method]);
141
142
const overrideMethod = (...args) => {
143
- const lastArg = args.length > 0 ? args[args.length - 1] : null;
144
- const alreadyHasComponentStack =
145
- lastArg !== null && isStringComponentStack(lastArg);
146
-
143
let shouldAppendWarningStack = false;
144
if (consoleSettingsRef.appendComponentStack) {
145
+ const lastArg = args.length > 0 ? args[args.length - 1] : null;
146
+ const alreadyHasComponentStack =
147
+ lastArg !== null && isStringComponentStack(lastArg);
148
+
149
// If we are ever called with a string that already has a component stack,
150
// e.g. a React error/warning, don't append a second stack.
151
shouldAppendWarningStack = !alreadyHasComponentStack;
@@ -176,10 +176,7 @@ export function patch({
176
current,
177
((method: any): 'error' | 'warn'),
178
// Copy args before we mutate them (e.g. adding the component stack)
179
- alreadyHasComponentStack
180
- ? // Replace component stack with an empty string in case there's a string placeholder for it.
181
- [...args.slice(0, -1), '']
182
- : args.slice(),
179
+ args.slice(),
180
);
181
}
182
}
packages/react-devtools-shared/src/backend/renderer.js
+1
-1
@@ -634,7 +634,7 @@ export function attach(
634
const breakOnConsoleErrors =
635
window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ === true;
636
const showInlineWarningsAndErrors =
637
- window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ === true;
637
+ window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ !== false;
638
if (appendComponentStack || breakOnConsoleErrors) {
639
patchConsole({
640
appendComponentStack,
packages/react-devtools-shared/src/hook.js
+1
-1
@@ -183,7 +183,7 @@ export function installHook(target: any): DevToolsHook | null {
183
const breakOnConsoleErrors =
184
window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ === true;
185
const showInlineWarningsAndErrors =
186
- window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ === true;
186
+ window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ !== false;
187
188
// The installHook() function is injected by being stringified in the browser,
189
// so imports outside of this function do not get included.