-
-
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
this.props.children and react/prop-types
rule
#7
Comments
Right, we should add an exception for |
Why should children be an exception? I think you should document when a component does accept or require children. |
You're right, but I rarely seen some propTypes for Maybe we can introduce an option to |
It seems to me like most components don't need I think the option idea is fine. I'm interested in hearing why anyone would want to run this against all other prop types, but never against children. It seems not well thought out to me, but I kind of hope I'm just missing something. |
All good points. [UPDATED]
In other cases when
|
I ended up with |
It looks like I have a combination of |
@remitbri thanks, I updated my comment above accordingly. What's your default prop value? |
|
Hmmm, my component is a wrapper, which could stand on its own, so I didn't set a default prop value. Bad practice? I guess if I had to set one then it should be |
Since 2.0.0 If you still want to ignore it you can use the |
@AsaAyers Won't |
yes, I think |
👍 Thanks, just making sure. |
Just to clarify, propTypes: {
children: React.PropTypes.node
} |
The this.props.children warning details can be found here: jsx-eslint/eslint-plugin-react#7 (comment)
I know this is closed, but wouldn't |
Not all Components have children. In a couple of my projects I have an |
@resistdesign actually yeah, OOP is not the main thing anymore, at least in React's world. |
Why do you need You should use |
Justin case you're wondering how to do that in Flow, use React.Node as described here: type Props = {
children: React.Node,
}; |
PropTypes.node can be an array, so no need the React.PropTypes.arrayOf(React.PropTypes.node) @sebastienbarre
|
Using
this.props.children
triggers the rule ("'children' is missing in props validation").Shouldn't it be an exception?
The text was updated successfully, but these errors were encountered: