Replies: 2 comments 2 replies
-
Looking at the source code, the mutate function swrInfinite returns only passes through revalidate. Which is obnoxious. Is there another approach that would work? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I am having trouble with pagination + optimistic updates too - is this broken? seems that the mutate work to change the value |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What I am doing and trying to achieve
I am using useSWRInfinite for the pagination feature and trying to update comments like state with bound mutate function with optimisticData option since I wanted to refresh the data immediately.(client-side perspective)
-> https://swr.vercel.app/docs/mutation#optimistic-updates and then get a new updated comment from axios and replace it with a previous comment that should be updated.
Expected
The data from useSWRInfinite should be updated right away since I am using optimisticData option until the API call is done and I could've set revalidate option to true but an async function in the mutate returns updated data with the response from axios. I didn't need it.
Actual behaviour
Even though I am passing optimisticData to the mutate, It doesn't update the data immediately. It keeps waiting until The API call is done and then gets updated.
What I've tried
I have tried using just the normal useSWR function without the pagination feature and it worked well as I expected.
I would really appreciate any help
Thank you :) 👍
Beta Was this translation helpful? Give feedback.
All reactions