Skip to content

useInfiniteQuery fetchNextPage function is inconsistent with refetch #2617

@lgenzelis

Description

@lgenzelis

Describe the bug

If you call fetchNextPage repeatedly, each call will result in the invocation fo the underlying async function, regardless of whether the first invocation has already resolved.
This behavior is inconsistent with that of e.g. refetch. If you call refetch 100 times in a row, before the first invocation has resolved, the underlying async function doesn't get re-invoked.

To Reproduce
Steps to reproduce the behavior:

  1. Go to this sandbox
  2. Open the console
  3. Click on the Refetch button repeatedly. You'll notice the line Fetching... printed on the console, just once (unless you wait more than 5 seconds, which is how long the async call takes to resolve)
  4. Click on the Fetch Next Page button repeatedly. You'll notice the line Fetching next page... printed on the console several times (once per button click)

Expected behavior
fetchNextPage should behave as refetch: you should see the line Fetching next page... printed only once.

Desktop (please complete the following information):

  • OS: macos
  • Browser: chrome
  • Version: 92

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions