Last active
August 8, 2018 01:44
-
-
Save aramis-it/720c1572effb221c4b74a17c03049de4 to your computer and use it in GitHub Desktop.
General form event listener direct field , object property
This file contains hidden or 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
// form event field | |
onFieldChange = e => { | |
this.setState({ [e.target.name]: e.target.value }); | |
}; | |
// form event Object property | |
onPropertyChange = e => { | |
this.setState({ | |
[e.target.dataset.model]: { | |
...this.state[e.target.dataset.model], | |
[e.target.name]: e.target.value | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment