-
Notifications
You must be signed in to change notification settings - Fork 46.2k
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
Issue: 5013 Added necessary code for firing warning if value is null #5048
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@@ -150,6 +161,8 @@ var ReactDOMSelect = { | |||
checkSelectPropTypes(inst, props); | |||
} | |||
|
|||
warnIfValueIsNull(props); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go into the if(__DEV__)
check above. We only fire warnings in dev mode.
We should make sure we only warn once for each error message. Otherwise, for an app that renders often, we will fill the error logs with 10,000 copies of this message. See how I did this in https://github.com/facebook/react/pull/5032/files with variables like |
@antoaravinth Ok, we're merging 0.15 stuff now. Can you rebase and fix the feedbacks above? Thanks! |
@jimfb : Sure. Once the merging is done, I can do the rebase and fix the issues that you have mentioned as well. Thanks. |
@antoaravinth Most of the 0.15 stuff is merged. I don't see any merge conflicts yet (I'm actually a little surprised, I expected #5032 to conflict). Anyway, we should go ahead and update this PR with the feedback above before merging this change in. You can do that by pushing your changes to the same branch in your github fork. |
@jimfb: Sure will do the same. |
@jimfb : Thanks for your help, I have rebased and pushed the necessary changes. Kindly let me know if anything else is pending from my side. |
@antoaravinth updated the pull request. |
if (props != null && props.value === null && !didWarnValueNull) { | ||
warning(false, '`value` prop on `textarea` should not be null.' + | ||
' Consider using the empty string to clear the component' + | ||
' `undefined` for uncontrolled components.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a missing " or " between component and undefined
Oops, correct PR, wrong person. I meant to ping @antoaravinth |
function warnIfValueIsNull(props) { | ||
|
||
if (props != null && props.value === null && !didWarnValueNull) { | ||
warning(false, '`value` prop on `input` should not be null.' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This formatting doesn't match our style, see any other warning or invariant callsite for examples.
Also, please remove the empty line above the condition.
Edit: further details on formatting long strings like this: blank space should go at the end of the preceding line.
'foo bar. ' +
'baz'
Fixed the lint issues Added logic for handling the warning only once and added the test cases for the same. Also moved the warning part to only DEV mode Changed few lines related to the formatting issues Removing the empty whitespace
@antoaravinth updated the pull request. |
Issue: 5013 Added necessary code for firing warning if value is null
Looks great, thanks @antoaravinth! |
This warning should really include the owner. |
Fix of the issue #5013. Let me know if anything else needs to be done. Thanks.