Closed mejackreed closed 3 years ago
When shallow rendering a component that has an inner displayName set wrapped in memo and forwardRef the displayName will be inaccurate.
memo
forwardRef
displayName
Discussion in material-ui https://github.com/mui-org/material-ui/issues/23831
Upstream behavior added in React: https://github.com/facebook/react/pull/18925
So given the following:
const Foo = () => <div />; Foo.displayName = 'CustomWrapper'; const MemoForwardFoo = React.memo(React.forwardRef(Foo)); expect(adapter.displayNameOfNode(<MemoForwardFoo />)).to.equal('Memo(ForwardRef(CustomWrapper))');
Currently : Memo([object object])
Memo([object object])
From the React work, I would expect this to be CustomWrapper, but within Enzyme, it seems more like Memo(ForwardRef(CustomWrapper)) is the expectation
CustomWrapper
Memo(ForwardRef(CustomWrapper))
Current behavior
When shallow rendering a component that has an inner displayName set wrapped in
memo
andforwardRef
thedisplayName
will be inaccurate.Discussion in material-ui https://github.com/mui-org/material-ui/issues/23831
Upstream behavior added in React: https://github.com/facebook/react/pull/18925
So given the following:
Currently :
Memo([object object])
Expected behavior
From the React work, I would expect this to be
CustomWrapper
, but within Enzyme, it seems more likeMemo(ForwardRef(CustomWrapper))
is the expectationYour environment
API
Version
Adapter