Here I have code of react table using hooks, and i have struggled on task where I need to set all rows and subrows expanded by default when i open the page, I have tried several solutions, but all of them didn't work.
Link to the code : https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/expanding
Just as I said, the option initialState.expanded allows you to expand the rows you want.
useTable(
{
columns: userColumns,
data,
initialState: {
expanded: { "0": true, "2": true }
}
},
useExpanded // Use the useExpanded plugin hook
)
This will expand the first and the third row.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With