Replies: 3 comments
-
@shuding this is probably one for you, massive kudos for your work on useSWRInfinite it's awesome. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I've dealt with a simular issue by mutating with useEffect and passing the mutator functions to all the "filtered lists" Essentially:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Hoping he discussion on #1156 will eventually lead to a documented solution, for now I'm having to use an undocumented solution which might break with future updates something like this:
|
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.
-
Caveat, I might be using useSWRInfinite and filtered lists in the wrong way so any pointers would be awesome.
I'm using useSWRInfinite for a feed list.
This feed list has filters like: All feed items, only posts, only activities.
Under the hood I think useSWRInfinite makes a new paginated cache for each filtered list.
An item might be in one or more of those cached list, so if I delete a feed item in one of the lists I want to update the data in all the other caches without having to call the API again and again for each cache.
I want to do something like:
May be I could import {mutate} I'm assuming this is not a hook and I can update global caches with a loop like this:
However, this doesn't work because:
3) I don't know what the key for the useSWRInfinite caches would be, I'm assuming it's the first page
4) I don't know if I am updating the paginated cache from useSWRInfinite correctly. The cache I get back from the useSWRInfinite bound mutate seemed to return an array and the cache I get back from the unbound mutate seems to be an object.
Any pointers would be massively appreciated, I would imagine that updating multiple caches for overlapping filtered infinite loading lists would be a fairly common use case.
Beta Was this translation helpful? Give feedback.
All reactions