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

Disable wrapping displayName with withStyles(…) #32

Closed
toddw opened this issue Oct 21, 2016 · 1 comment
Closed

Disable wrapping displayName with withStyles(…) #32

toddw opened this issue Oct 21, 2016 · 1 comment

Comments

@toddw
Copy link

toddw commented Oct 21, 2016

We use enzyme in our tests and it lets you use selectors like wrapper.find("MyComponent") but because of how react-with-styles renames the displayName we have to use wrapper.find("withStyles(MyComponent").

The line causing this is here:

WithStyles.displayName = `withStyles(${wrappedComponentName})`;

Would you be open to merging something that would allow us to make this optional?

@lencioni
Copy link
Collaborator

Hi @toddw! Thanks for the question!

It is best to use wrapper.find() with a reference to the component instead of a string that describes the component (e.g. wrapper.find(MyComponent), not wrapper.find("MyComponent")). This will solve this problem for you when using any HOC, while also avoiding accidentally finding a different component than the one you expected that may have the same name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants