Created
November 14, 2019 00:14
-
-
Save hipertracker/65d1329ab40afd33b074c0c9a733b46e to your computer and use it in GitHub Desktop.
React synchronous setState
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
setStateSynchronous(stateUpdate) { | |
return new Promise(resolve => { | |
this.setState(stateUpdate, () => resolve()); | |
}); | |
} | |
// https://stackoverflow.com/questions/42018342/is-there-a-synchronous-alternative-of-setstate-in-reactjs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment