Repository navigation
useSWRInfinite: await setSize(totalPageCount) will not wait to load all pages. #4148
Replies: 2 comments
|
If that's the case, I think even when using parallel requests, setSize should resolve only after all the requested data is completely received. |
|
I can reproduce the early return on SWR 2.5.1, including with When the extra pages aren't cached, In a local hook test, I started with one cached page and held the next two requests open. If the next step needs every page, base that step on the hook's state instead: const ready = !isValidating && !error &&
data?.length === totalPageCount &&
data.every(page => page !== undefined);For example, use that condition to enable an export button, or to run a guarded effect once loading finishes. Handle AI-assisted; checked with real React hooks and deferred fetch promises, including a failed-page case. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Does
await setSize(totalPageCount)not wait for all the page data to be requested because I used theparallel: trueparameter?All reactions