React-table: Pagination not working correctly when used with the 'useSortBy' hook

Created on 27 Mar 2020  路  3Comments  路  Source: tannerlinsley/react-table

Describe the bug (required)
The pageIndex state property resets to 0 after loading the next page

Provide an example via Codesandbox! (required)
Use a new react-table codesandbox to reproduce the issue.
https://codesandbox.io/s/interesting-hertz-01fnh

Steps To Reproduce (required)
Steps to reproduce the behavior:

  1. Go to the codesandbox
  2. Click on the next button '>'
  3. Notice how the pageIndex resets back to 0

Expected behavior (Recommended)
The pageIndex should not change after the data for the new page has been loaded.

Most helpful comment

Scratch my last comment...

You need to set manualSortBy to true along with manualPagination otherwise it will reset the pageIndex each time the sort state changes, you will need to handle the actual sorting in your fetchData call

You will also need to set autoResetPage to false, see https://github.com/tannerlinsley/react-table/blob/d2acfc423593389f8f7b974c6f544ecf683f0724/docs/api/usePagination.md for details

All 3 comments

Scratch my last comment...

You need to set manualSortBy to true along with manualPagination otherwise it will reset the pageIndex each time the sort state changes, you will need to handle the actual sorting in your fetchData call

You will also need to set autoResetPage to false, see https://github.com/tannerlinsley/react-table/blob/d2acfc423593389f8f7b974c6f544ecf683f0724/docs/api/usePagination.md for details

鈽濓笍 馃挴

thanks! will try that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

panfiva picture panfiva  路  3Comments

LeonHex picture LeonHex  路  3Comments

tremby picture tremby  路  3Comments

Abdul-Hameed001 picture Abdul-Hameed001  路  3Comments

bdkersey picture bdkersey  路  3Comments