-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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?
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.
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.
@akulsr0 ok so, for custom components, className
isn't special and is just like any other prop. For HTML elements, it is special and doesn't need a propType.
What are the next steps?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3749 +/- ##
==========================================
+ Coverage 94.47% 97.60% +3.12%
==========================================
Files 134 133 -1
Lines 9613 9473 -140
Branches 3486 3470 -16
==========================================
+ Hits 9082 9246 +164
+ Misses 531 227 -304 ☔ View full report in Codecov by Sentry. |
21ba4c5
to
9ac517f
Compare
Closes #3284