Skip to content

Commit

Permalink
fix a bug in console.log with non-string args (#24546)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondaychen authored May 12, 2022
1 parent 34da5aa commit 852f10b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/react-devtools-shared/src/backend/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ export function formatWithStyles(
inputArgs === undefined ||
inputArgs === null ||
inputArgs.length === 0 ||
typeof inputArgs[0] !== 'string' ||
// Matches any of %c but not %%c
(typeof inputArgs[0] === 'string' && inputArgs[0].match(/([^%]|^)(%c)/g)) ||
inputArgs[0].match(/([^%]|^)(%c)/g) ||
style === undefined
) {
return inputArgs;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-devtools-shared/src/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ export function installHook(target: any): DevToolsHook | null {
inputArgs === undefined ||
inputArgs === null ||
inputArgs.length === 0 ||
typeof inputArgs[0] !== 'string' ||
// Matches any of %c but not %%c
(typeof inputArgs[0] === 'string' &&
inputArgs[0].match(/([^%]|^)(%c)/g)) ||
inputArgs[0].match(/([^%]|^)(%c)/g) ||
style === undefined
) {
return inputArgs;
Expand Down

3 comments on commit 852f10b

@vpontis
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR broke things: https://stackoverflow.com/questions/72216782/uncaught-typeerror-inputargs0-match-is-not-a-function

@mondaychen I started getting errors when doing:

  const router = useRouter();
  console.log(router.query)

in next.js

It's also weird that the Chrome Extension isn't listed in the Chrome Extension Store now...

@vpontis
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe this fixes things and this commit isn't released. Your PR says it should fix the issue I'm finding. But it's very odd that the Chrome Store doesn't have the extension anymore..

@mondaychen
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vpontis this is because it (usually) take a day for each version of an extension to be reviewed before it can be published on chrome web store. Please refer to #24543 and #24549 for details. This issue is resolved now.

Please sign in to comment.