Last active
July 17, 2017 17:11
-
-
Save coryhouse/9bd989ec8f89e3fcf058129b67a509ad to your computer and use it in GitHub Desktop.
Consise example of object spread in React
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
updateState({target}) { | |
this.setState({user: {...this.state.user, [target.name]: target.value}}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes it does, which is why I added "I know that it's not always avoidable".
'name
andvalue
are no brainers, getting the current user fromstate
is less so. I'm always struggling with my devs to write Clean Code, but know "when to say when". I think the right answer is somewhere on this page, but I'm not sure which one it is. ;)I'd be happy to take a look and give you my feedback.