Skip to content

initialPageParam in useInfiniteQuery shouldn't default to zero #2340

Open
@mevansAI

Description

@mevansAI

Description

Currently pageParam in use infinite query is set to 0 if initialPageParam is undefined. While this makes sense in some cases, the backend my react app is fetching from uses mikro-orms implementation of a cursor, where the cursor is represented by an opaque string rather than a sequential number, so the correct way to get the 1st page in my implementation is to omit a cursor value completely from the request (and then use the response from that query to get the cursor for the subsequent pages).

Currently this library doesn't support that implementation as if I set initialPageParam: undefined it will set pageParam to 0 and send api-endpoint?cursor=0 in the http request to my backend api which will throw an error.

Proposal

  • Remove the default value of 0 for pageParam. Consequence of this is if a default value of zero is required it must be explicitly set as initialPageParam: 0
    OR
  • Provide an option to override this default value or omit cursor from the http request

Any other suggestions are welcome.

Extra

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