Skip to content

Instantly share code, notes, and snippets.

@hipertracker
Created November 14, 2019 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hipertracker/65d1329ab40afd33b074c0c9a733b46e to your computer and use it in GitHub Desktop.
Save hipertracker/65d1329ab40afd33b074c0c9a733b46e to your computer and use it in GitHub Desktop.
React synchronous setState
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