React Table v6 expanded subrows after page change

393 views Asked by At

I am able to show all the subrows on my table using the defaultExpanded property like this -

const defaultExpandedRows = data.map((element, index) => {
  return { index: true };
});

...

<ReactTable
  ...
  defaultExpanded={defaultExpandedRows}
  ...
/>

My problem is that this only works on the initial page load, and when I click on the next page, none of the subrows are expanded.

Page 1, initial load: enter image description here

Page 2: enter image description here

Is there a way to keep all the subrows open, even after the re-renders from page change?

1

There are 1 answers

0
AudioBubble On

Figured it out, just needed to add an expanded={defaultExpandedRows}