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

Issue: 5013 Added necessary code for firing warning if value is null #5048

Merged
merged 1 commit into from
Oct 15, 2015
Merged

Issue: 5013 Added necessary code for firing warning if value is null #5048

merged 1 commit into from
Oct 15, 2015

Conversation

antsmartian
Copy link
Contributor

Fix of the issue #5013. Let me know if anything else needs to be done. Thanks.

@facebook-github-bot
Copy link

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 [email protected]. Thanks!

@facebook-github-bot
Copy link

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);
Copy link
Contributor

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.

@jimfb
Copy link
Contributor

jimfb commented Oct 5, 2015

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 didWarnCheckedLink

@jimfb jimfb added this to the 0.15 milestone Oct 5, 2015
@jimfb
Copy link
Contributor

jimfb commented Oct 7, 2015

@antoaravinth Ok, we're merging 0.15 stuff now. Can you rebase and fix the feedbacks above? Thanks!

@antsmartian
Copy link
Contributor Author

@jimfb : Sure. Once the merging is done, I can do the rebase and fix the issues that you have mentioned as well. Thanks.

@jimfb
Copy link
Contributor

jimfb commented Oct 8, 2015

@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.

@antsmartian
Copy link
Contributor Author

@jimfb: Sure will do the same.

@antsmartian
Copy link
Contributor Author

@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.

@facebook-github-bot
Copy link

@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.');
Copy link
Contributor

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

@jimfb
Copy link
Contributor

jimfb commented Oct 14, 2015

@pluma Looks like there are still two commits in this PR. Maybe try squashing one more time?

@spicyj This looks good to me. Any last change requests before we merge?

@pluma
Copy link
Contributor

pluma commented Oct 14, 2015

@jimfb Yeah, that's because you're looking at the wrong PR 😉

Hint: #5140 is the one you should be looking at.

@jimfb
Copy link
Contributor

jimfb commented Oct 14, 2015

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.' +
Copy link
Member

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
@facebook-github-bot
Copy link

@antoaravinth updated the pull request.

@antsmartian
Copy link
Contributor Author

@zpao @jimfb Done, let me know if anything else is needed from my side.

jimfb added a commit that referenced this pull request Oct 15, 2015
Issue: 5013 Added necessary code for firing warning if value is null
@jimfb jimfb merged commit b735dd4 into facebook:master Oct 15, 2015
@jimfb
Copy link
Contributor

jimfb commented Oct 15, 2015

Looks great, thanks @antoaravinth!

@sophiebits
Copy link
Collaborator

This warning should really include the owner.

@jimfb
Copy link
Contributor

jimfb commented Oct 15, 2015

@spicyj Yeah, that would be good. How would we feel about including the parent/debug path from #5167?

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

Successfully merging this pull request may close these issues.

6 participants