Is there a way to reset pages of `useSWRPages`?
See original GitHub issueHi
I’m using swr for pagination in my local next.js project. My implementation is based on this example.
The difference is that my component with useSWRPages
is using dynamic route, which loads user’s feed, and the route looks like this: /user/[username]
.
The problem appears when I switch user feed with loaded pages. In more details:
- I, as a user, open user-A’s feed, then load a number of pages (let’s say 4).
- I change feed to user-B’s.
- User-B’s feed loads 4 pages, instead of 1.
I’d tried to pass username in to useSWRPages
’s deps, and use it in key, but it didn’t helped me. Is there any workarounds? Maybe I should pass something else in to the deps?
There’s is an issue that seems like similar to mine: #126.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:17
- Comments:28 (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 >Using Paginated Data with SWR by sergiodxa - Sergio Xalambrí
Along with useSWR , the SWR library gives us a useSWRPages hook which lets us do paginated data. The way it works is...
Read more >An Introduction To SWR: React Hooks ... - Smashing Magazine
In this article, we'll be looking at a new way of retrieving data in React Apps named SWR. This is a set of...
Read more >issues within React and rendering a compnent - Stack Overflow
Recently I'm trying to use this library: https://github.com/zeit/swr/blob/master/examples/pagination/pages/page-index.js but I just added one ...
Read more >How To Reset Explore Page On Instagram - YouTube
Let's reset the Instagram explore page if you don't like what the Instagram app shows you on the search or for you page....
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
Any progress on this?
Currently you can try
as a temporary work around.
I will work on simplifying the
useSWRPages
API next week since it’s tricky to get it right (conditional and dependent hooks) and we have several bugs/feature requests around it. 🙏