swr: Can not mutate data from SWRInfinite with `revalidateFirstPage: false` when key is not mounted

Bug report

I can not manually refresh data using mutate when using SWRInfinite and revalidateFirstPage: false and key of that mutate is not bound to current page.

Description / Observed Behavior

I have a list of items, which I fetch using useSWRInfinite. Since I do not want to fetch the first page everytime user fetches next page, I use it with revalidateFirstPage: false option, and that works great. So, imagine I have a list of items: A, B, C, D, E. Each item have also its own details page. I can change item A to Aa and use mutate when I am on list page to refresh cache without calling request again, and that also works. The problem is when I go to page A and change that item’s name to Aa - even though I call exactly the same methods, when I go back to list page, the item is still A, not Aa. I tested it a lot of times, and that scenario works when I remove revalidateFirstPage: false from useSWRInfinite. But without it I have to load first page every time user scrolls down, which slows down loading new data…

Expected Behavior

Cache is always updated when using mutate, but first page is not fetched everytime when I want to fetch n+1 page

Additional Context

SWR version 1.2.0

About this issue

Most upvoted comments