Issue (bug?) with useSWRInfinite and initialData #788
Unanswered
grazianodev
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.
-
I'm trying to use 'useSWRInfinite' with SSR in a Next.js project. The following component fetches a list of posts, with the first page of posts ('initialPosts') fetched on the server:
My problem is that when I click on 'Load more' the first time, my fetcher correctly fetches the second page of posts, however the new posts are not appended to 'data', so I still only see the first page of posts (fetched on the server). Am I doing something wrong or could this be a bug? Shouldn't 'data' be updated to include the second page of posts too?
If I click on 'Load more' again, the app fetches the second and third pages of posts, which replace the first page. After that, clicking on 'Load more' works as expected, i.e. one page a time is fetched.
Beta Was this translation helpful? Give feedback.
All reactions