-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
hasClassName throws Error if component has property className which is not a string #452
Comments
This is documented in #375, you can watch that issue for updates! Thanks! |
Also, classnames doesn't return an object. It takes an object and returns a string based on the key's value. import classNames from 'classnames'
const className = classNames({
foo: true,
bar: true,
baz: false
});
// returns "foo bar" |
Hi, Thanks for your input. Might be that I misunderstand the proposed fix in the referenced issue, but after I looked through the PR that is connected with the ticket you referenced, it seems to me that it will not solve the issue. They are discussing a SVG specific solution(using
Wouldn't it be more appropriate in the Also, in the issue you linked, it seems to me that the proposed fix only affects the full rendering functionality, not the shallow part. Best regards |
Thanks for expanding, we can re-open this as I agree that |
Is this still an issue in v3? |
Hi,
We use a utility like JedWatsons classnames(https://github.com/JedWatson/classnames) for setting classnames on our components. Syntax is like this:
This makes the internal hasClassName and all functions in the api blow up with the exception
TypeError: classes.replace is not a function
since the propertyclassName
is a object.In my view the hasClassName function should not throw a exception if it encounters a custom component with a className attribute that is not a string. From my usage of enzyme I have the assumption that you are generally looking for native components when the hasClassName function is used. If that assumption is considered true I am tempted to suggest the following patch:
It could probably also be possible to take the defined proptype into consideration.
/Joakim
The text was updated successfully, but these errors were encountered: