In this official example, table sorting and searching resets on blur of any editable field.https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/kitchen-sink?file=/src/App.js
How can I prevent that? I want sort and search to stay the same, even if someone edits the data.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With