-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async render, rather than async state #3918
Comments
We've gone back and forth on this; there are benefits to both. This would solve the case where you're setting your state based on your current Instead, our recommendation is to use the function form of setState so instead of
you write
We're not planning to change this anytime soon; any improvements will probably be along the lines of making the APIs more functional to support this better. |
This is something that have wondered me too. As a workaround I use another object to store state and use |
Wrote some thoughts about why React works this way here: #11527 (comment) |
Having run into several issues related to reading state that has been set but not yet committed to the component's state, I've been wondering why
setState
is asynchronous at all. Wouldn't it be better to do an async render instead? This would allow you to synchronously update state all you want, with the same performance benefits of async state changes.I'm imagining:
setState
mutates state immediatelyThoughts?
The text was updated successfully, but these errors were encountered: