You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I've come to understand, SWR Infinite by default always fetches the zeroth page alongside the current one. The data is then compared to the cache, so that if anything on it has changed, it fetches again all pages at once. #1401 (comment)
I cannot seem to trigger this behavior. When the zeroth page changes, all middle pages remain the same, which produces skips and duplicate keys in the list.
Expected Behavior
With the default configuration, SWR should revalidate all pages if the zeroth page does not correspond to its cache.
Repro Steps / Code Example
I've modified the SWR Infinite example of the docs to add a +1 button that appends a new item to the beginning of the list. Click +1 any number of times and then click load more and see how it starts to become more and more inconsistent. The data in the codesandbox is purely local, but I'm able to trigger this with a live API. https://codesandbox.io/p/sandbox/swr-infinite-forked-qltkgj
Additional Context
The codesandbox I linked uses v2, but I noticed this on my app which has v2.2.5.
The text was updated successfully, but these errors were encountered:
alvvaro
changed the title
Infinite does not revalidate all pages when the first one changes
Infinite does not revalidate all pages when the zeroth one changes
May 18, 2024
I cannot seem to trigger this behavior. When the zeroth page changes, all middle pages remain the same, which produces skips and duplicate keys in the list.
I think this behavior is for cursor-based API, but your example is a page-based API.
You're right, I misread the comment from shuding. He was explicitly talking about cursor-based APIs.
However I'm now more confused, since a cursor sidesteps the content shift problem entirely. The revalidation waterfall he talks about is not necessary in that case? Can this waterfall even happen, like is it a feature that exists in code?
Sorry, I'll be happy to close this issue and open a discussion about this, because I was clearly mistaken.
Bug report
Description / Observed Behavior
As I've come to understand, SWR Infinite by default always fetches the zeroth page alongside the current one. The data is then compared to the cache, so that if anything on it has changed, it fetches again all pages at once. #1401 (comment)
I cannot seem to trigger this behavior. When the zeroth page changes, all middle pages remain the same, which produces skips and duplicate keys in the list.
Expected Behavior
With the default configuration, SWR should revalidate all pages if the zeroth page does not correspond to its cache.
Repro Steps / Code Example
I've modified the SWR Infinite example of the docs to add a +1 button that appends a new item to the beginning of the list. Click +1 any number of times and then click load more and see how it starts to become more and more inconsistent. The data in the codesandbox is purely local, but I'm able to trigger this with a live API.
https://codesandbox.io/p/sandbox/swr-infinite-forked-qltkgj
Additional Context
The codesandbox I linked uses v2, but I noticed this on my app which has v2.2.5.
The text was updated successfully, but these errors were encountered: