How to prevent react-table sort and search reset

Viewed 1628
1 Answers

When using sortBy you can set this property to false

autoResetSortBy: Boolean

  • Defaults to true
  • When true, the sortBy state will automatically reset if any of the following conditions are met: data is changed
  • To disable, set to false

https://react-table.tanstack.com/docs/api/useSortBy

The same thing for filtering

autoResetFilters: Boolean

  • Defaults to true
  • When true, the filters state will automatically reset if any of the following conditions are met: data is changed
  • To disable, set to false

https://react-table.tanstack.com/docs/api/useFilters

Also see this FAQ https://react-table.tanstack.com/docs/faq#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes

Edit For completeness, one can also set autoResetGlobalFilter on the global filter: see documentation.

Related