I'm looking for an easy and clean way to make all rows to be auto-expanded when using react-table v7.
When I map all the data to true and set it as an initial state, it does not expand my rows.
const expanded = {
1: true,
2: true,
...
};
...
useTable(
{
...
initialState: {
expanded
}
}
);
By dumping table state expanded prop, I've found out there are generated non-numeric keys like {Col1:somevalue2: true} (grouped columns). I don't have an access to those keys before table instance is created and therefore I also don't have an access to row ids in order to generate initial state.
The only way I've found is below but I'd prefer the tableInstance to be expanded initially (as a result of useTable() hook).
React.useEffect(() => tableInstance.toggleAllRowsExpanded(true), []);
Relevant Github FR discussion: https://github.com/tannerlinsley/react-table/discussions/3317