在这个官方示例中,表格排序和搜索会在任何可编辑字段模糊时重置。 https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/kitchen-sink?file=/src/App.js
我怎样才能防止这种情况发生?我希望排序和搜索保持不变,即使有人编辑了数据。
最佳答案
使用 sortBy 时,您可以将此属性设置为 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
过滤也是一样
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
编辑
为了完整起见,还可以在全局过滤器上设置 autoResetGlobalFilter
:see documentation .
关于javascript - 如何防止 react 表排序和搜索重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62450548/