Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using React.memo(React.forwardRef(Component)) displayName will be inaccurate #2481

Closed
2 of 13 tasks
mejackreed opened this issue Dec 7, 2020 · 0 comments · Fixed by #2482
Closed
2 of 13 tasks

Comments

@mejackreed
Copy link
Contributor

Current behavior

When shallow rendering a component that has an inner displayName set wrapped in memo and forwardRef the displayName will be inaccurate.

Discussion in material-ui mui/material-ui#23831

Upstream behavior added in React: facebook/react#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])

Expected behavior

From the React work, I would expect this to be CustomWrapper, but within Enzyme, it seems more like Memo(ForwardRef(CustomWrapper)) is the expectation

Your environment

API

  • shallow
  • mount
  • render

Version

library version
enzyme 3.11.0
react >= 16.6
react-dom >= 16.6
react-test-renderer 16.14.0
adapter (below)

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-16.3
  • enzyme-adapter-react-16.2
  • enzyme-adapter-react-16.1
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant