Skip to content
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

Bug: useOptimistic hook showing stale values #31912

Open
CodingReaper1 opened this issue Dec 25, 2024 · 3 comments
Open

Bug: useOptimistic hook showing stale values #31912

CodingReaper1 opened this issue Dec 25, 2024 · 3 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@CodingReaper1
Copy link

React version: "^18" I tried on "^18.3.1" as well
image
image

The current behavior

Number and button appears for like 0.1 second and then dissapears
first i had this setup with database and little more complex ui then i reduced it to very simple arrays with number and button
Btw i did try this with useTransition as well neither that neither action works

The expected behavior

Number with button should appear without dissapearing

@CodingReaper1 CodingReaper1 added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Dec 25, 2024
@vezaynk
Copy link

vezaynk commented Dec 28, 2024

What do you expect to happen? You don't have a non-optimistic to actually track persistent state, nor do you have async work.

@CodingReaper1
Copy link
Author

@vezaynk I expected component to show up and do not dissapear, I did have async work before I changed it to this simple array it was no different from what happening now, am I missing something? can you show me some code example or explain more what should be done?

@vezaynk
Copy link

vezaynk commented Dec 28, 2024

@CodingReaper1 useOptimistic values are discarded after a transition has completed.optimisticNumbers will only show the optimistic result while the operation is running.

Once it has completed, non-optimistic state is expected to either catch up or be canceled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

2 participants