-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
Bug: React.Node should not have true
, or PropTypes.node warns it
#17871
Comments
true
, or PropTypes.node warns ittrue
, or PropTypes.node warns it
Note; I’m not claiming that, I’m suggesting it as a possible history. Clarification would be appreciated. |
Why is this the expected behavior?
<div />
<div></div>
<div>{false}</div>
<div>{null}</div>
<div>{undefined}</div>
<div>{true}</div> The docs have said this since back through 2016 (when I stopped tracing). type Props = {
component: React.Node
}; IMO this prop type says "I require something React can render to be passed as a |
I’m wondering if perhaps true was invalid prior to react 15? |
Not sure! I wasn't on the team before v15. 🙂 I don't think that would change my stance on this issue though. I don't think this is a bug or requires any change from React. |
It requires a change in prop-types, however, (which i maintain) so it’d be useful to determine exactly when it changed. That said, there’s probably nothing actionable for react to do at this point and the issue can be closed. |
Right, my comment was only meant for React. Looks like there's a separate issue filed against |
Did some testing; looks like React 15 disallowed |
React version: 16.8.6
Steps To Reproduce
The current behavior
Flow does not emit error (as React.Node accepts
true
), but PropTypes.node emits below runtime error in browser's console.The expected behavior
Flow emits type error.
According to a maintainer of prop-types, formerly React itself did not accept
true
for JSX node (in flowReact.Node
) (so not changing prop-types for now), is it right?The text was updated successfully, but these errors were encountered: