I got a react Table that I want to delete or modify my data. My code is below for all my cells.
deleteTableElement = (row) => {
let data = this.state.list.data;
data.splice(row.id, 1);
this.setState({
list:{
...this.state.list,
data:data
}
})
};
actionsCell = (columns) => {
columns.push({
Header: "Accion",
Cell: (props) => {
console.log(props);
return (
<div
style={{
display: "flex",
justifyContent: "space-around",
}}
>
<i
onClick={() => this.deleteTableElement(props.row)}
className="material-icons"
style={{ color: "red", cursor: "pointer" }}
>
delete
</i>
</div>
);
},
});
return columns;
};
In this case, I want to modify the item. The react table is not updating.
? and what is data structure of
columns`? – HindemithactionsCell
? – Ervinervinee.values = {...e.values, id:xvar}
, now i need the solution for deleting a row – Kidderminstersplice
mutates state. Don't do it. Usefilter
instead. – Flawedconsole.log(this.state.list);
before and after splice. – Ervinervine(!this.state.list) ?return "Loading...": <DataTable {...this.state.list} />
– Kidderminster