Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useSWRInfinite does not return data until all pages are fetched #2989

Open
sarioglu opened this issue Jul 5, 2024 · 2 comments
Open

useSWRInfinite does not return data until all pages are fetched #2989

sarioglu opened this issue Jul 5, 2024 · 2 comments

Comments

@sarioglu
Copy link

sarioglu commented Jul 5, 2024

Bug report

Description / Observed Behavior

When combined with { initialSize: 10 }, I expect useSWRInfinite to load first 10 pages one by one, by passing data for each page as it's fetched. However, it waits for all 10 pages to be fetched and return all data in one pass.

Expected Behavior

I expect it to return each page as it is available, without waiting for all to finish fetching.

Additional Context

SWR version: 2.2.5

@Sergio16T
Copy link

Hello @sarioglu. I believe the following option will help your use-case.

https://swr.vercel.app/docs/pagination.en-US#parallel-fetching-mode

@sarioglu
Copy link
Author

Hi @Sergio16T, thank you for your response. What I need is something slightly different. I want to be able to show each page as soon as it's been fetched. Loading them in parallel makes it faster but it'll still wait till all the pages are fetched.

What I need is more like Load page1 -> data: [page1] -> Load page2 -> data: [page1, page2] -> ... -> Load page 10 -> data: [page1, ..., page10] and not Load page1 -> Load page2 -> ... -> Load page10 -> data: [page1, ..., page10]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants