Skip to content

Instantly share code, notes, and snippets.

@beausmith
Created May 2, 2018 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beausmith/51b426d4ee484250a8a1a228011ffffc to your computer and use it in GitHub Desktop.
Save beausmith/51b426d4ee484250a8a1a228011ffffc to your computer and use it in GitHub Desktop.
One React method to control all html form elements
updateInputValue = ({ currentTarget: { name, value, checked, type } }) => {
this.setState({
[name]: type === 'checkbox' ? checked : value || this.initialState[name]
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment