reactjsreact-table

React Table removes Filters when updating data


I am using the material ui kitchen sink example of react table (https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/material-UI-kitchen-sink)

My data updates frequently, the issue is, that the filters are cleared everytime I update the data. You can try this by setting a filter in the codesandbox example and changing a value in a cell. onBlur it sets the state and with that the filters are cleared and checkboxes are unchecked.

Is there a way to prevent that or a solution/workaround for it?

Thank you very much!


Solution

  • Set auto reset flag for global filters to false -

    autoResetGlobalFilter: false
    

    Fixed CSB - https://codesandbox.io/s/strange-oskar-sqefh?file=/src/components/EnhancedTable.js:3191-3226

    More details - https://react-table.tanstack.com/docs/api/useGlobalFilter#table-options