-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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
Fix controlled/uncontrolled validation for radio+checkbox inputs #7003
Conversation
cc @spicyj |
31c0b79
to
38f06f2
Compare
function isControlled(props) { | ||
return ((props.type === 'checkbox' || props.type === 'radio') && props.checked !== undefined) || | ||
(props.type !== 'checkbox' && props.type !== 'radio' && props.value !== undefined); | ||
} |
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 spacing isn't FB style and this would be clearer anyway; can you change it?
function isControlled(props) {
var usesChecked = props.type === 'checkbox' || props.type === 'radio';
return usesChecked ? props.checked !== undefined : props.value !== undefined;
}
38f06f2
to
2152f5b
Compare
@jimfb updated the pull request. |
checked={false} | ||
onChange={() => null} | ||
/>, container); | ||
console.log(console.error.calls.argsFor(0)[0]); |
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.
Did you mean to leave this console.log
call here? 😃
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.
Pssh, thanks. #7006
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.
We need a lint rule for that.
semver labels on this and #7006 please? |
(cherry picked from commit 0bb0fe8)
Fix controlled/uncontrolled validation for radio+checkbox inputs
Fixes #6779