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
[Fix] prop-types: className
missing in prop validation
#3749
base: master
Are you sure you want to change the base?
[Fix] prop-types: className
missing in prop validation
#3749
Conversation
@@ -634,6 +634,8 @@ module.exports = function propTypesInstructions(context, components, utils) { | |||
// So we should construct an optional children prop | |||
this.shouldSpecifyOptionalChildrenProps = true; | |||
|
|||
this.shouldSpecifyClassNameProp = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need a class property for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since react generic type would have className
too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what i mean is, when is this not always true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So whenever the type is coming from react import reference, then we can have className
too (similar to children).
When its not true is: type annotation, type literal, etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
className
is just a prop, though, like any other. I'm a bit confused why it merits special treatment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
className
is a react specific prop for HTML elements. class
is a vanilla HTML attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that's all true - but HTML elements don't use propTypes, so we're only talking about custom components here.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3749 +/- ##
==========================================
- Coverage 97.71% 97.60% -0.12%
==========================================
Files 133 133
Lines 9470 9473 +3
Branches 3469 3470 +1
==========================================
- Hits 9254 9246 -8
- Misses 216 227 +11 ☔ View full report in Codecov by Sentry. |
Closes #3284