dillon1000/react
Commit
Browse files [devtools] allow non-coercible objects in formatConsoleArgumentsToSingleString (#31444)
## Summary
We have been getting unhandled `TypeError: Cannot convert object to
primitive value` errors in development that only occur when using
devtools. I tracked it down to `console.error()` calls coming from
Apollo Client where one of the arguments is an object without a
prototype (created with `Object.create(null)`). This causes
`formatConsoleArgumentsToSingleString()` in React's devtools to error as
the function does not defend against `String()` throwing an error.
My attempted fix is to introduce a `safeToString` function (naming
suggestions appreciated) which expects `String()` to throw on certain
object and in that case falls back to returning `[object Object]`, which
is what `String({})` would return.
## How did you test this change?
Added a new unit test.Changed paths2 files
First-parent comparisonpackages/react-devtools-shared/src/__tests__/utils-test.js ModifiedM packages/react-devtools-shared/src/backend/utils/index.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…