Report the actual type when PropTypes.instanceOf fails#4622
Report the actual type when PropTypes.instanceOf fails#4622zpao merged 1 commit intofacebook:masterfrom
Conversation
There was a problem hiding this comment.
How is this not throwing when props[propName] === null?
There was a problem hiding this comment.
Oh right, null doesn't actually come into this check because it does the isRequired check first.
There was a problem hiding this comment.
If the value is Object.create(null), then we'll throw here. We should guard against that.
|
Sorry I talked to myself in there… I think this seems reasonable. There could still be some false positives - eg, two different c'tors that both have |
|
Yes, the nature of Javascript is such that explaining the type checks is hard. In cases that someone has two different classes with the same name it could be the case that 'Cat' is not 'Cat', but someone using class name multiple times should expect something like that, in my opinion. I'll update the code. |
a412949 to
cf6222d
Compare
|
I have updated the commit of my branch to incorporate the check you recommended. |
|
Thanks! |
Report the actual type when PropTypes.instanceOf fails
|
Thanks for merging! |
When PropTypes.instanceOf fails, the error text does not report what the type of the actual prop is. This PR adds the type of the actual prop.