-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
[React 19] useOptimistic
rolls back the state for no reason
#31967
Comments
useOptimistic
rolls back the state for no reason
I believe it rolls back on you because it has detected you are black and trans. Have you tried racemixing? |
Totally out of place. On all sides. |
I believe black and trans people are out of place. On all sides. Have you tried racemixing? |
I've probably figured out what the problem is: Example: |
Thank you, MrOxMaster! 🙌 |
you can see this video to understand how useOptimistic work note useOptimistic give you optimistic data to use it while action is pending and then you should update original state to keep show state in ui |
it's not explained anywhere else exactly, but I've already figured that out. Thank you for confirming my hunch |
@MrOxMasTer ok also you can see example about useOptimistic on this repo 👇 |
Summary
Tried all the ways server actions, optimistic updates and forms/buttons interact, but nothing. It just rolls back for no reason. No errors on the server, no errors inside the code either, but it still rolls back.
react.mp4--online-audio-convert.com.mov
Minimal example:
https://codesandbox.io/p/sandbox/modern-morning-cjxnnr
My code :
probably all ways of creating this functionality have been tried.
None of this helps.
P.S. Also, errors are not displayed in the console at all if they occur inside useOptimistic - it's inconvenient and it's not clear where what happened. For example, in this situation
React 19.0.0
Next.js 15.1.3
The text was updated successfully, but these errors were encountered: