Skip to content

onPaginationChange when used on client side, always returns pageIndex 0 #5970

Open
@karolis-palsauskas-devoteam

Description

TanStack Table version

"@tanstack/react-table": "^8.21.2"

Framework/Library version

"react": "^18.3.1"

Describe the bug and the steps to reproduce it

Hey,

Through app we use both client and server side pagination. In all cases we are required to update URL params to reflect pagination (page, page size, sort applied, etc.). Because of this on client side pagination I provide custom "onPaginationChange" which includes URL update method

When implementing table, I encountered behavior where "onPaginationChange":

  • Is fired even when sorting is applied
  • When fired, always returns pageIndex 0, even if initial value was any other value

Possible bug: "onPaginationChange" returns incorrect prevState when used in "client" mode?

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/sandbox/k3dnff

Screenshots or Videos (Optional)

Image

going directly to any other page, and clicking "Next", in console.log you can see it returns pageIndex 0

If you change mode to "server" everything works as expected

Do you intend to try to help solve this bug with your own PR?

None

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

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