-
Notifications
You must be signed in to change notification settings - Fork 45.9k
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
Missing documentation: null/undefined as input value #11031
Comments
Sorry about the confusing redirects. We rewrote the docs last year and did best effort redirects, but it's worth updating some of the warnings to better locations. If I recall it right, the reason for this warning is just because we wanted to change the behavior for |
Thank you for filing this issue! 😄 The documentation and source code for reactjs.org now lives in a different repository: reactjs/reactjs.org. (For more info on why we made this move, see issue #11075.) I've moved your issue to the new repo: reactjs/react.dev#16 Let's continue the discussion there! Sorry for the inconvenience. |
Is there a reason this is still the case? I think it's a strange rule as it's normal to use |
Do you want to request a feature or report a bug?
I'd like to request documentation. :-)
When you pass
null
asvalue
of an input, you get the following warning:This warning very clearly states what to do. My problem is, it fails to mention why I'm not supposed to pass
null
. Nor could I find any explanation online:null
.value={undefined}
is not controlled component" adds the following documentation: "Similarly to not setting thevalue
attribute at all, setting it tonull
orundefined
will make React assume the component is not controlled and may produce a warning." But again, there is no explanation as to why React behaves this way.Naively, I'd expect
null
to be a perfectly valid value, e.g. for a numeric input that is empty. Passing an empty string to indicate the absence of a numeric value seems odd to me. So I'd really like some more information in the documentation!The text was updated successfully, but these errors were encountered: