-
Notifications
You must be signed in to change notification settings - Fork 49k
Description
Edit See this comment for the key part of what's being reported/discussed on this issue: #22315 (comment)
Original bug report below
As of #18561 component stacks are generated from native stack frames. This is problematic with HOCs that inherit from the input component in order to change its behavior. The somewhat popular @risingstack/react-easy-state package is one example of such a component. While it does assign a displayName
, the new Native Component Stacks appear to ignore this. Instead, components wrapped in view()
(from react-easy-state) are always shown with the name of the wrapper class, i.e., ReactiveComp
or ReactiveClassComp
.
This is especially catastrophic in the case of react-easy-state, where one is supposed to wrap essentially all components in the entire codebase in the view()
HOC. The result is that component stacks become unusable for debugging.
Is there perhaps a way to work around this (e.g. disable native component stacks, or some new way to explicitly provide a component name like displayName
)?
React version: 17.0.1
Steps To Reproduce
- Apply a HOC that uses inheritance (i.e., inherits from the component instead of wrapping it in JSX) to a component.
- The component will always be named
ReactiveComp
orReactiveClassComp
in component stack traces.
Link to code example: https://codesandbox.io/s/rough-tdd-wqepe?file=/src/App.tsx
The current behavior
Something went wrong.
Error: sorry
BadGuy@https://7ww9j.csb.app/src/App.tsx:21:9
ErrorBoundary@https://7ww9j.csb.app/src/App.tsx:33:5
div
App
Something went wrong.
Error: sorry
ReactiveComp@https://7ww9j.csb.app/node_modules/@risingstack/react-easy-state/dist/es.es6.js:62:53
ErrorBoundary@https://7ww9j.csb.app/src/App.tsx:33:5
div
App
Note how the component wrapped in view()
is shown as ReactiveComp
instead of either the function name or the explicitly assigned displayName
.
The expected behavior
The name of the ReactiveComp
wrapper should never appear in component stacks.