Using global mutate to revalidate a specific page when using useSWRInfinite #2271
Unanswered
otterlistic
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug report
The
mutate
method exposed viauseSWRInfinite
is only ideal for situations when you want to revalidate/refetch all the pages (all the data corresponding to a specific pageIndex) which I would argue is quite the rare use case.If you want to revalidate/refetch a specific page you would want to use the global
mutate
method, however when you provide the exact key that maps to a particular page a revalidation/refetch does not happen.Description / Observed Behavior
A refetch/revalidate does not happen when you call the global mutate method with the intention of refetching a single page with a specific key that maps to that specific page.
Expected Behavior
I would expect it to be possible to revalidate a single page if the key matches the page via global mutate when using useSWRInfinite.
Repro Steps / Code Example
Assume each post is a page that is an array of objects, I am aware that what's done in the reproduction can be easily achieved using
useSWR
. This just makes it easier to demonstrate the problem.Link
Additional Context
SWR version: 1.1.2
Beta Was this translation helpful? Give feedback.
All reactions