How can I get updated data from my API with useSWRInfinite? #1344
Unanswered
MichaelBurgess
asked this question in
Q&A
Replies: 1 comment
-
I just tried using the How can I invalidate all the data with this bound |
Beta Was this translation helpful? Give feedback.
0 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
When I use
useSWR
, I can callmutate
(not the one returned from the hook, but the one exported from the package) on my API path, which will then cause the hook to refetch the data from the API and my component(s) update on screen.E.g.
When I use
useSWRInfinite
, after I mutate my keys related to that API (I'm using cursor pagination), the component I have on screen doesn't refetch from the API.FYI the
getKey
is as follows:...so in the
useSWRInfinite
example, after I mutate the key(s) related to the API (e.g. with the page size and next token),data
does not return the updated value from the API and I need to force a revalidation by changing page and back, or by clicking out the browser and back.I was seeing this issue with both
0.5.6
and with the latest beta releases where I'm able to provide my own cache and do regex matches on the keys that I want to clear.What am I doing wrong? How can I make
useSWRInfinite
refetch the data from the API after I invalidate the key(s) that it is using?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions