Am trying to keep the state of selected checkboxes for a react-table v7. I have a checkbox that can select multiple rows at once and works great, the issue is the table can't maintain that state once a dialog opens up for batch actions. The checkboxes become unchecked immediately the dialog is opened even though the selected rows data is still available. I just need the checkboxes to keep state. The data is fetched from a graphql api and the polling is set to 0
Most of the code used is the same as the documentation
const TableContainer = ({ columns, data }) => {
const {
getTableProps,
getTableBodyProps,
headerGroups,
page,
prepareRow,
canPreviousPage,
canNextPage,
pageOptions,
pageCount,
gotoPage,
nextPage,
previousPage,
setPageSize,
setGlobalFilter,
selectedFlatRows,
state: { pageIndex, pageSize, globalFilter },
} = useTable(
{
columns,
data,
defaultColumn: { Filter: DefaultColumnFilter },
initialState: { pageIndex: 0, pageSize: 10 },
},
useFilters,
// useExpanded,
useGlobalFilter,
useSortBy,
usePagination,
useRowSelect,
(hooks) => {
hooks.visibleColumns.push((columns) => [
{
id: "selection",
Header: ({ getToggleAllRowsSelectedProps }) => (
<Checkbox {...getToggleAllRowsSelectedProps()} />
),
Cell: ({ row }) => {
return <Checkbox {...row.getToggleRowSelectedProps()} />;
},
},
...columns,
]);
}
); // return
Any inputs in the react hooks are able to keep the data entered well without issue. Only change is on the table. Any help is appreciated