Skip to content
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

Closed
DanielSWolf opened this issue Oct 2, 2017 · 3 comments
Closed

Missing documentation: null/undefined as input value #11031

DanielSWolf opened this issue Oct 2, 2017 · 3 comments

Comments

@DanielSWolf
Copy link

Do you want to request a feature or report a bug?

I'd like to request documentation. :-)

When you pass null as value of an input, you get the following warning:

warning.js:33 Warning: value prop on select should not be null. Consider using the empty string to clear the component or undefined for uncontrolled components.

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:

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!

@gaearon
Copy link
Collaborator

gaearon commented Oct 2, 2017

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 null. So not using it ensures your code won't break when we do change it. We haven't changed it yet.

@bvaughn
Copy link
Contributor

bvaughn commented Oct 6, 2017

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.

@bvaughn bvaughn closed this as completed Oct 6, 2017
@ThaJay
Copy link

ThaJay commented Mar 18, 2019

If I recall it right, the reason for this warning is just because we wanted to change the behavior for null. So not using it ensures your code won't break when we do change it. We haven't changed it yet.

Is there a reason this is still the case? I think it's a strange rule as it's normal to use null as explicitly not a value, as opposed to undefined which means does not exist and react enforces null as a return value when explicitly not returning a component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants