-
-
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
require-default-props natively #1184
Comments
It should not; |
I understand what you're saying but from the React source I remember only a couple of things happening to defaultProps:
Advantages of destructuring:
Maybe I'm missing what you mean by optimize. AFAIK React doesn't do component optimization on pure functions. It could be an option for the rule like:
|
#666 may be relevant here. |
The issue is indeed related in a manner as it is the exact opposite of what I want. Also the rule proposal is aptly named The scope of the rule should be to assign a default value in order to prevent undefined property values. Am I correct in this assumption? |
My interpretation of the original intent of the rule is to require a defaultProps entry for each non-required propType, not to prevent undefined property values (especially since |
I see your point. Still wondering if there's a way to circumvent the use of default props, especially if developers use Flow instead of propTypes. |
Flow is not a complete replacement for PropTypes, as there's many things custom propType validators can do that Flow can't. I don't see the issue in using both Flow and |
@ljharb for functional components, seems like the preferred way is to use ES6 defaults. See this facebook/flow#7467 |
Given the following example:
Understandably the above code does not use the defaultProps assignment but I'm wondering if this should be added as an acceptable case considering that under ES6 destructuring rules this should be a perfectly valid case of property assignment.
The text was updated successfully, but these errors were encountered: