Using the material-table library. I would like to replicate the behavior shown in this example.
https://codesandbox.io/s/table-hover-colors-zw9nt
https://www.npmjs.com/package/material-table
https://material-table.com/#/
I was thinking of using onRowClick={}
The logic would be
onRowClick =>
- set value in component state that renders clicked rows background to a different color
- set all other rows to background to the original color
I can use conditional rendering based on a value held in state to change the background. Although this changes the background for all rows.
options={
rowStyle:{backgroundColor: this.state.selected ? '#fff' : this.state.c}
}
My current working example is here https://codesandbox.io/s/peaceful-haibt-2nefw
Thanks for your help