question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to disable revalidating the first page when changing the size in useSWRInfinite

See original GitHub issue

Bug 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

  1. Clone master
  2. Add console.log(...args) to examples/infinite-scroll/libs/fetch.js
  3. npm install && npm run dev
  4. 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:closed
  • Created 2 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
shudingcommented, Oct 9, 2021

There is now a revalidateFirstPage option in swr@beta 🎉

10reactions
shudingcommented, Sep 16, 2021

I reopened and changed it to a feature request. 👍 If the API is cursor based it makes sense to have this option.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found