Disable wrapping `displayName` with `withStyles(…)`
toddw opened this issue · comments
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:
react-with-styles/src/withStyles.jsx
Line 62 in ea72776
Would you be open to merging something that would allow us to make this optional?
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.