Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Feature Request: Alternative to isLoading for useSWRInfinite #2399

Closed
VladimirMikulic opened this issue Jan 30, 2023 · 0 comments
Closed

Feature Request: Alternative to isLoading for useSWRInfinite #2399

VladimirMikulic opened this issue Jan 30, 2023 · 0 comments
Labels
area: pagination Pagination related issues

Comments

@VladimirMikulic
Copy link

Description / Observed Behavior

isLoading only applies to the initial / first request.
I have a project with many infinite scrolls and this is the line which is repeated (taken from your infinite loading example):

const isLoadingMore =
    isLoadingInitialData ||
    (size > 0 && data && typeof data[size - 1] === "undefined");

isLoadingMore in this case is true while the next page data is being loaded and false otherwise:

  • Request to /page/
  • isLoadingMore = true
  • Request to /page/ done
  • isLoadingMore = false

I was wondering if it would be possible to expose a property like isLoadingMore for useSWRInfinite so we avoid repeating this block for every infinite scroll in the app. Or maybe make isLoading to be true for all loading useSWRInfinite requests? (i.e. regardless of whether it's initial request or subsequent)

Repro Steps / Code Example

https://swr.vercel.app/examples/infinite-loading

Additional Context

SWR: v2.0.3

@koba04 koba04 added the area: pagination Pagination related issues label Feb 7, 2023
@vercel vercel locked and limited conversation to collaborators Feb 7, 2023
@koba04 koba04 converted this issue into discussion #2410 Feb 7, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
area: pagination Pagination related issues
Projects
None yet
Development

No branches or pull requests

2 participants