0

i'm using data-table in react i have a lot of row and one cell in this row editable. onBlur function i'm getting the changed value and push to some array with this way.

let editedData = []

 editedData.push({
   total: this.state.data[cellInfo.index][cellInfo.column.id],
   id: cellInfo.row._original.id,
   comment: cellInfo.row.comment
 });

there is unique id of each row. Everything work well but my records are repeating.

so is like:

0: {total: "40222", id: "c296b0f2-0ed9-49fa-bf33-e14151a197d5", comment: null}
1: {total: "40222222", id: "c296b0f2-0ed9-49fa-bf33-e14151a197d5", comment: null}

here is total property is coming from editable input. i want to make prevent duplicating record in my editedData array.

how realize this logic?

if this id already is have in my editedData array just change total property ?

user3348410
  • 2,733
  • 10
  • 51
  • 85

0 Answers0