I have a column in my react table that is using a variable (named item) for displaying its data. As shown in the code below:
{
Header: this.generateHeaderCell(this.props.headers[3]),
accessor: 'last_updated_status',
Cell: (props: any) => <DateSinceFormat date={props.value} item={item}/>,
maxWidth: 85,
filterable: false
}
So when the value of variable item is 1 it displays some data and when it's changed it displays something else.
I am using the onClick event for changing the value of item.
onRowClick = (state, rowInfo, column, instance) => {
return {
onClick: e => {
if(item === '2') {
item = '1';
} else {
item = '2';
}
instance.forceUpdate();
}
};
}
The problem I face here is, I only want to update the value for a particular row, that is clicked by the user, however, right now all the rows are getting updated.
Please help me out here and let me know how to fix this issue.