Replies: 1 comment 1 reply
-
I had to patch this locally so that the infinite call is correctly removed when clearing the cache. |
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a question about the behavior of the global mutate of useSWRInfinite. Let's take an example of the Interest List page on an e-commerce site. Tabs such as all, shoes, pants exist for category filters. The following code is used to manage this as a single hook.
The problem occurs in editing situations. If you delete one product from the shoes tab and call
mutate
(return value ofuseSWRInfinite
), the products on the shoes tab will be revalidated successfully.However, if you go to the all tab, the deleted shoe product remains. If you delete it from the shoes tab and call
mutate(key bound mutate)
, only pages with the/interests?tab=shoes&offset={number}
key will be revalidate. This action can be understood from an optimization point of view.I tried to use global mutate to solve this edge case, but the data with infinite key was not revalidated. I looked up some related codes to find out why.
It was confirmed that the returned key was internally hashed and added a prefix of
$inf$
inuseSWRInfinite
. Keys with$inf$
were skipping revalidate from the global mutator.I know it's being skipped from the comments, but I'm wondering if there's any particular reason to skip it.
I'm also wondering if I can solve the above problem by the method provided by the SWR.
Beta Was this translation helpful? Give feedback.
All reactions