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
React.PropTypes.node should accept stateless component (function) #5527
Comments
What about adding new propType validator? Something like propTypes: {
optionalComponent: React.PropTypes.component
} where component would have form of PropTypes.oneOfType([ PropTypes.node, PropTypes.func ]) or something similar. In my opinion it is quite dangerous to let people pass in functions, but I'm not sure how to make better validation. Reading |
Can you show how you were using this? I don't think Component Classes should have been valid for |
Oh my god. You are so right. I feel stupid. I guess I was validating something the bad way. Sorry for the noise. |
I just replaced some react components that where defined using es6 classes and I am now getting warnings about my react stateless component (that are just fuction) not being a ReactNode.
I were validating some components using
React.PropTypes.node
, but now I need to usePropTypes.oneOfType([ PropTypes.node, PropTypes.func ])
which seems a bit long to say "this can be anything that can be rendered as a component" (which is whatProTypes.node
is supposed to cover right?).From the doc
Maybe
func
should be added? Or is there any reason whynode
doesn't handlefunc
as well?The text was updated successfully, but these errors were encountered: