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 always make 2 calls for api (page 1 and page n) #1706

Closed
Ilya-Valasiuk opened this issue Dec 13, 2021 · 2 comments
Closed

useSWRInfinite always make 2 calls for api (page 1 and page n) #1706

Ilya-Valasiuk opened this issue Dec 13, 2021 · 2 comments

Comments

@Ilya-Valasiuk
Copy link

Ilya-Valasiuk commented Dec 13, 2021

Bug report

Description / Observed Behavior

What kind of issues did you encounter with SWR?

Always 2 requests sends to API:

  1. with page number 1
  2. with page number N

Expected Behavior

1 request should be created with page N

How did you expect SWR to behave here?

Repro Steps / Code Example

Install https://github.com/vercel/swr/tree/main/examples/infinite-scroll

Take a look in Network tab
image

Or share your code snippet or a CodeSandbox link is also appreciated!

Additional Context

SWR version.
Add any other context about the problem here.

It works as expected for very old version :) Example - https://swr.vercel.app/examples/infinite-loading

@shuding
Copy link
Member

shuding commented Dec 13, 2021

Duplicate of #1638, as I explained there:

Since SWR 1.1.0, there is a new option revalidateFirstPage that you can use to turn this off. Related docs: https://github.com/vercel/swr/releases/tag/1.1.0

If you are interested, here are the full discussions of why we built this feature in the first place: #1401 (comment), and why we now provide this new option to customize it.

Let me know if it helps you!

@shuding shuding closed this as completed Dec 13, 2021
@Ilya-Valasiuk
Copy link
Author

@shuding thank you, got it

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