Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextPage() / previousPage() not changing the state of the table #5375

Closed
2 tasks done
marceloverdijk opened this issue Feb 27, 2024 · 1 comment
Closed
2 tasks done

Comments

@marceloverdijk
Copy link
Contributor

TanStack Table version

v8.12.0

Framework/Library version

Vanilla JS

Describe the bug and the steps to reproduce it

I'm trying to get a Vanilla JS implementation up and running and I made some good progress.
The table is created and rendered to html, including pagination buttons.

However, when calling nextPage() / previousPage() I try to update the state of the table but it seems not to be updated.
So when re-rendering it still renders always the first page.

Is this a bug in table-core or expected behavior and do I need to do something else to manage the state?

The reproducible example mentioned below is an easy setup and should be self explanatory.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://stackblitz.com/edit/github-6xqt97?file=main.js

Screenshots or Videos (Optional)

image

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

Maybe, I'll investigate and start debugging

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.
@KevinVandy
Copy link
Member

It's because you hardcoded the pagination state, instead of storing it in state. In your code, the pageIndex will always be 0, and the pageSize will always be 10. You're making it so it cannot change.

I'm guessing you meant to use initialState instead of state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants