I am using DataTable
component from prime-react in my React application to create a data table. I want to change the colour of the row when it's double clicked. However, when another row is clicked, the colour of the previous highlighted row should be changed back to original colour. I went through the docs but prime-react doesn't seem to provide an API to change row colours. So what will be the best way to achieve this?
I can change the row colour like this but I don't see an efficient way to change back colours of all other rows. Plus it's not a good practice to use vanilla JavaScript to modify DOM?
const highlightRow = event => {
event.originalEvent.currentTarget.classList.add('highlighted-row');
};
<DataTable
value={props.values}
onRowDoubleClick={event => highlightRow(event)}
>
CSS:
.highlighted-row {
background-color: blue;
}