Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Last active September 6, 2018 16:46
Show Gist options
  • Select an option

  • Save agoiabel/498b04ebf0f718ad3baaa7468a1e6acb to your computer and use it in GitHub Desktop.

Select an option

Save agoiabel/498b04ebf0f718ad3baaa7468a1e6acb to your computer and use it in GitHub Desktop.
changeHandler = event => {
const name = event.target.name;
const value = event.target.value;
const updatedControls = {
...this.state.formControls
};
const updatedFormElement = {
...updatedControls[name]
};
updatedFormElement.value = value;
updatedFormElement.touched = true;
updatedFormElement.valid = validate(value, updatedFormElement.validationRules);
updatedControls[name] = updatedFormElement;
this.setState({
formControls: updatedControls
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment