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
Comments
Same problem here! Did you find any solution? |
Hi! No, unfortunately I don't have any news |
Can't you use const { mutate } = useSWRConfig(); ? or perhaps Reacts useOptimistic, I use these in combination with useSWR to do optimistic changes instanly clientside without waiting for the server to finish mutating and revalidating the tag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 totrue
when the button is clicked, but it is stillundefined
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.
The text was updated successfully, but these errors were encountered: