Skip to content

[RTK Query] - provide query args in infinite queries getNextPageParam / getPreviousPageParam #4957

@papsavas

Description

@papsavas

The current limit & offset implementation does not allow for dynamic query limits. Each query is stuck to its initialPageParam.

Take for example this following getNextPageParam implementation

  getNextPageParam: (currentPage, allPages, currentPageParam, allPageParams) => {
      if (currentPage.data.length === 0) return undefined;
      const page = currentPageParam.page + 1;
      // const offset = currentPageParam.offset + queryArgs.limit
      return { page };
    },

There is no way to calculate offset because queryArgs is not provided, only pageParams.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions