fix a bug in console.log with non-string args (#24546)
Mengdi "Monday" Chen committed
May 12, 2022 at 10:29 UTC
852f10b5cf188f8aa797f9a809f0caeaa95a4231
2 files changed
+4
-3
packages/react-devtools-shared/src/backend/utils.js
+2
-1
@@ -181,8 +181,9 @@ export function formatWithStyles(
181
inputArgs === undefined ||
182
inputArgs === null ||
183
inputArgs.length === 0 ||
184
+ typeof inputArgs[0] !== 'string' ||
185
// Matches any of %c but not %%c
185
- (typeof inputArgs[0] === 'string' && inputArgs[0].match(/([^%]|^)(%c)/g)) ||
186
+ inputArgs[0].match(/([^%]|^)(%c)/g) ||
187
style === undefined
188
) {
189
return inputArgs;
packages/react-devtools-shared/src/hook.js
+2
-2
@@ -180,9 +180,9 @@ export function installHook(target: any): DevToolsHook | null {
180
inputArgs === undefined ||
181
inputArgs === null ||
182
inputArgs.length === 0 ||
183
+ typeof inputArgs[0] !== 'string' ||
184
// Matches any of %c but not %%c
184
- (typeof inputArgs[0] === 'string' &&
185
- inputArgs[0].match(/([^%]|^)(%c)/g)) ||
185
+ inputArgs[0].match(/([^%]|^)(%c)/g) ||
186
style === undefined
187
) {
188
return inputArgs;