How can i set a row with prop active={true} on click Table.Row React semantic UI
Sounds simple but I didn't find a way to do it. in the documentation I found nothing talking about.
I tried that way, but not worked,
selectRow(key){
let rowStatus = this.state.rowStatus[];
for(let i in rowStatus){
rowStatus[i] = false;
}
rowStatus[key] = true;
this.setState({rowStatus:rowStatus});
}
renderRowTable(data){
let row = [];
let rowStatus = [];
for(let i in data){
rowStatus.push(false);
row.push(
<Table.Row key={i} active={this.state.rowStatus[i]} onClick={()=>{this.selectRow(i)}}>
<Table.Cell title={data[i].code}>{data[i].code}</Table.Cell>
<Table.Cell title={data[i].date}>{data[i].date}</Table.Cell>
</Table.Row>
);
}
this.setState({
row:row,
rowStatus:rowStatus
});
}
render() {
return (
<div>
<Table celled fixed singleLine compact size="small" sortable selectable>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Code</Table.HeaderCell>
<Table.HeaderCell>Date</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>{this.state.row}</Table.Body>
</div>
)
}