Skip to content

Instantly share code, notes, and snippets.

@marr
Last active July 26, 2016 18:31
Show Gist options
  • Save marr/c4007bda0e03bfdd1426faa311cac098 to your computer and use it in GitHub Desktop.
Save marr/c4007bda0e03bfdd1426faa311cac098 to your computer and use it in GitHub Desktop.
handleChange(e) {
const form = e.currentTarget
const { formValues } = this.state
const valid = Array.from(form.elements).every(el => {
if (el.name) {
formValues[el.name] = el.value
}
return el.validity.valid
})
this.setState({
formValues,
valid
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment