Skip to content

Commit 50393dc

Browse files
author
Brian Vaughn
authored
React Native fixes for new inline errors feature (facebook#20502)
1 parent 09a2c36 commit 50393dc

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

packages/react-devtools-shared/src/__tests__/inspectedElementContext-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,8 @@ describe('InspectedElementContext', () => {
20142014
Object {
20152015
"errors": Array [
20162016
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",
20182019
1,
20192020
],
20202021
],

packages/react-devtools-shared/src/backend/console.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ export function patch({
140140
targetConsole[method]);
141141

142142
const overrideMethod = (...args) => {
143-
const lastArg = args.length > 0 ? args[args.length - 1] : null;
144-
const alreadyHasComponentStack =
145-
lastArg !== null && isStringComponentStack(lastArg);
146-
147143
let shouldAppendWarningStack = false;
148144
if (consoleSettingsRef.appendComponentStack) {
145+
const lastArg = args.length > 0 ? args[args.length - 1] : null;
146+
const alreadyHasComponentStack =
147+
lastArg !== null && isStringComponentStack(lastArg);
148+
149149
// If we are ever called with a string that already has a component stack,
150150
// e.g. a React error/warning, don't append a second stack.
151151
shouldAppendWarningStack = !alreadyHasComponentStack;
@@ -176,10 +176,7 @@ export function patch({
176176
current,
177177
((method: any): 'error' | 'warn'),
178178
// 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(),
183180
);
184181
}
185182
}

packages/react-devtools-shared/src/backend/renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ export function attach(
634634
const breakOnConsoleErrors =
635635
window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ === true;
636636
const showInlineWarningsAndErrors =
637-
window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ === true;
637+
window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ !== false;
638638
if (appendComponentStack || breakOnConsoleErrors) {
639639
patchConsole({
640640
appendComponentStack,

packages/react-devtools-shared/src/hook.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export function installHook(target: any): DevToolsHook | null {
183183
const breakOnConsoleErrors =
184184
window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ === true;
185185
const showInlineWarningsAndErrors =
186-
window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ === true;
186+
window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ !== false;
187187

188188
// The installHook() function is injected by being stringified in the browser,
189189
// so imports outside of this function do not get included.

0 commit comments

Comments
 (0)