Created
September 14, 2018 15:39
-
-
Save squalvj/3542f7746e1a5e99a8ad93c147673103 to your computer and use it in GitHub Desktop.
React, SetState Callback
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
_onClickHandler: function _onClickHandler() { | |
console.log('State before (_onClickHandler): ' + JSON.stringify(this.state)); | |
this.setState({ | |
dollars: this.state.dollars + 10 | |
}, () => { | |
console.log('Here state will always be updated to latest version!'); | |
console.log('State after (_onClickHandler): ' + JSON.stringify(this.state)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment