How to properly get the next page based on all previous data using useSWRInfinite? #1060
Unanswered
potouridisio
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I need to get the next 100 data that aren't the ones I have.
I can't request per page or offset because I have random results from different databases.
It would be ideal if
getKey
callback was called withpageIndex
anddata
(all pages), since given thepageIndex
youcan access the
previousPageData
.Instead of that I've tried creating a closure so
getKey
has access to data,or in my fetcher function
I tried keeping the data in
useState
oruseRef
, updating them inonSuccess
callback or in auseEffect
and I've either ended up having infinite loops, sending double requests or data not being updated the right moment.So I'm asking and I'd appreciate it if there's anyone that has implemented something similar and can help.
Beta Was this translation helpful? Give feedback.
All reactions