Skip to content

useInfiniteQuery's implementation disregards falsy nextCursor value #766

@DennisOluoch

Description

@DennisOluoch

How useInfiteQuery hook was designed to function is that when getFetchMore queries for data and nextCursor/nextId/nexPage/cursor (or whatever the name you give) returns a falsy value or no value at all then the function (getFetchMore) should abort querying for next data otherwise we'll start from beginning which will cause unwanted duplication. However, that's not the case. getFetchMore disregards the falsy value and goes ahead to query data. So we end up with a query like for example:- /api/projects?cursor=null which returns duplicate data.

To Reproduce
Steps to reproduce the behavior:

  1. Run load-more-infinite-scroll example from react-query's examples directory
  2. I'm running v2.5.1 of react-query but the bug should suffice in v2 and above

Expected behavior
useInfinteQuery should abort fetching data when nextId/nexCursor/nextPage is null

Additional context
If it's not a bug then maybe the implementation changed a great deal that we are not aware of

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