We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The useSWRInfinite hook fires a double request every time there is a setSize(size + 1) call.
setSize(size + 1)
This only happens in SWR version 1.x. Everything works fine with version 0.x.
There should only be 1 request per setSize call.
setSize
This is the official example found in the pagination documentation. It uses SWR 0.3:
https://codesandbox.io/s/swr-infinite-z6r0r?from-embed=&file=/src/App.js
This is the exact same example, but uses SWR 1.0.1:
https://codesandbox.io/s/swr-infinite-1-0-double-api-call-issue-fbvzs
If you open the network tab, you will see multiple request fired every time you click "load more" .
SWR version: 1.x
The text was updated successfully, but these errors were encountered:
I just encountered this exact issue right now and it seems to happen exclusively on 1.x
1.x
Sorry, something went wrong.
related to #1401
Given #1401, I think this is an expected behavior and the issue can be closed.
As @shuding said there, the solution is:
There is now a revalidateFirstPage option in swr@beta 🎉
No branches or pull requests
Bug report
Description / Observed Behavior
The
useSWRInfinite
hook fires a double request every time there is asetSize(size + 1)
call.This only happens in SWR version 1.x. Everything works fine with version 0.x.
Expected Behavior
There should only be 1 request per
setSize
call.Repro Steps / Code Example
This is the official example found in the pagination documentation. It uses SWR 0.3:
https://codesandbox.io/s/swr-infinite-z6r0r?from-embed=&file=/src/App.js
This is the exact same example, but uses SWR 1.0.1:
https://codesandbox.io/s/swr-infinite-1-0-double-api-call-issue-fbvzs
If you open the network tab, you will see multiple request fired every time you click "load more" .
Additional Context
SWR version: 1.x
The text was updated successfully, but these errors were encountered: