Created
May 2, 2018 23:17
-
-
Save beausmith/51b426d4ee484250a8a1a228011ffffc to your computer and use it in GitHub Desktop.
One React method to control all html form elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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