You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React and React DevTools generate component stacks in the same format as native Error stacks. For user components (class and function components) this is done by intentionally causing the component's render method to throw an Error, and then stitching the error stack frames together:
But for "host components" (e.g. HTMLDivElement or View) when we have no source location to show, we fall back to showing just "at div" or "at View".
We could probably more closely mirror what JavaScript engines do by appending a "location" like (native) or (unknown location) (as the v8 docs suggest) or (anonymous) as v8 seems to actually do in testing.
The trick would be matching the specific browser/engine's behavior for this. For example, running the following code in Chrome or Node...
JSON.stringify({},()=>console.log(newError('')));
...will show the stack frame:
at JSON.stringify (<anonymous>)
while Firefox will show:
Error:
<anonymous> file:///path/to/script:7
Improving this format so that host components more closely mirror native Error stacks will help simplify things like React Native's error parsing.
The text was updated successfully, but these errors were encountered:
React and React DevTools generate component stacks in the same format as native Error stacks. For user components (class and function components) this is done by intentionally causing the component's render method to throw an Error, and then stitching the error stack frames together:
react/packages/react-devtools-shared/src/backend/DevToolsComponentStackFrame.js
Lines 62 to 203 in 5fa4d79
This results in a component stack like this:
But for "host components" (e.g.
HTMLDivElement
orView
) when we have no source location to show, we fall back to showing just "at div" or "at View".We could probably more closely mirror what JavaScript engines do by appending a "location" like
(native)
or(unknown location)
(as the v8 docs suggest) or(anonymous)
as v8 seems to actually do in testing.The trick would be matching the specific browser/engine's behavior for this. For example, running the following code in Chrome or Node...
...will show the stack frame:
while Firefox will show:
Improving this format so that host components more closely mirror native Error stacks will help simplify things like React Native's error parsing.
The text was updated successfully, but these errors were encountered: