This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
react-testing does not print name of component wrapped in memo correctly #1237
Labels
Area: dev experience
Package: react-testing
stale
Stale issue that hasn't received any attention in a while
Type: Bug 🐛
Something isn't working
Overview
I was recently testing some stuff in web when I came across a case where react-testing was not returning the name of a component correctly and was instead falling back to the default of "Component"
I would have expected that to say:
I believe this is because this Toast component in question is the one from polaris which is a Component wrapped in a React.memo, rather than a plain old functional component.
I suspect this is because the printType utility does not correctly handle finding the name for components that are wrapped in
React.memo()
. I'd wager components wrapped inReact.forwardRef()
are also affected in the same way. You should also test components that are doReact.memo(React.forwardRef(function SomeComponent() { return 'hi'; }))
facebook/react#17274 from the react repo might be some useful related reading as it fixes up some logic around how names are extracted from these exotic components in the react dev tools.
The text was updated successfully, but these errors were encountered: