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

Optimistic update with useSWRMutation #2924

Open
thebat93 opened this issue Mar 27, 2024 · 2 comments
Open

Optimistic update with useSWRMutation #2924

thebat93 opened this issue Mar 27, 2024 · 2 comments

Comments

@thebat93
Copy link

Bug report

Description / Observed Behavior

I'm trying to implement an optimistic update with useSWRMutation.
For some reason the data doesn't change optimistically. It is waiting for the fetcher resolve and then changes.
optimisticData is called, but it doesn't do anything.

Expected Behavior

Please see the attached example.
data should change rightaway to true when the button is clicked, but it is still undefined until the promise resolves.

Repro Steps / Code Example

https://codesandbox.io/p/sandbox/hopeful-bouman-cr27yt

Additional Context

SWR version: 2.2.5.
Add any other context about the problem here.

@MoSattler
Copy link

Same problem here! Did you find any solution?

@thebat93
Copy link
Author

Hi! No, unfortunately I don't have any news

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants