Option to disable revalidating the first page when changing the size in useSWRInfinite
See original GitHub issueBug report
Description / Observed Behavior
Running the infinite-scroll example on the latest release (1.0.0), I observe that the first page gets re-fetched on every call to setSize(size + 1)
Expected Behavior
setSize(size +1)
should only fetch the next page.
Repro Steps / Code Example
- Clone master
- Add
console.log(...args)
toexamples/infinite-scroll/libs/fetch.js
npm install && npm run dev
- Inspect console logs as you scroll.
Additional Context
Changing the version of swr in the example back to 0.5.6 and updating the import of useSWRInfinite , this doesn’t happen.
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Pagination - SWR
SWR is a React Hooks library for data fetching. SWR first returns the data from cache (stale), then sends the fetch request (revalidate),...
Read more >useSWRInfinite with pagination and mutate features
I am using useSWRInfinite for the pagination feature and trying to ... API call is done and I could've set revalidate option to...
Read more >How to use SWR in Next JS - client-side data-fetching technique
You can update the data of your page in real-time by using SWR with no ... (And Where Not To); useSWR Support for...
Read more >swr: Versions | Openbase
This is a new added option for useSWRInfinite (defaults to true ), you can use it to control if the first page should...
Read more >SWR v1 is here: What's new? - LogRocket Blog
The revalidation of stale data occurs under the hood on user focus or ... You can enable this by setting the refreshInterval option...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
There is now a
revalidateFirstPage
option inswr@beta
🎉I reopened and changed it to a feature request. 👍 If the API is cursor based it makes sense to have this option.