Skip to content

Commit 852f10b

Browse files
authored
fix a bug in console.log with non-string args (#24546)
1 parent 34da5aa commit 852f10b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ export function formatWithStyles(
181181
inputArgs === undefined ||
182182
inputArgs === null ||
183183
inputArgs.length === 0 ||
184+
typeof inputArgs[0] !== 'string' ||
184185
// Matches any of %c but not %%c
185-
(typeof inputArgs[0] === 'string' && inputArgs[0].match(/([^%]|^)(%c)/g)) ||
186+
inputArgs[0].match(/([^%]|^)(%c)/g) ||
186187
style === undefined
187188
) {
188189
return inputArgs;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ export function installHook(target: any): DevToolsHook | null {
180180
inputArgs === undefined ||
181181
inputArgs === null ||
182182
inputArgs.length === 0 ||
183+
typeof inputArgs[0] !== 'string' ||
183184
// Matches any of %c but not %%c
184-
(typeof inputArgs[0] === 'string' &&
185-
inputArgs[0].match(/([^%]|^)(%c)/g)) ||
185+
inputArgs[0].match(/([^%]|^)(%c)/g) ||
186186
style === undefined
187187
) {
188188
return inputArgs;

0 commit comments

Comments
 (0)