useSWRInfinite with two data loading directions #2096
Unanswered
bogdan-fortum
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.
-
Hi!
I have a question about data fetching strategy or idea for a problem that I'm facing in nextjs app.
I have a bar chart that has a horizontal scroll. The x axis on the chart has months displayed as bars for each year. The idea with the chart is that when the user reaches either end of the chart with scrollbar, it should fetch additional page with year(s). There are 2 data loading scenarios here:
Consider that I'm loading 2 items per each request
I managed to load the past data, but not sure how to set the
size
when I need to load the future dataI was also able to do this without swr library by keeping 2 page indexes and setting each one based on the scroll direction user makes. But I'm falling short when trying to utilise the
useSWRInfinite
Beta Was this translation helpful? Give feedback.
All reactions