Answer the question
In order to leave comments, you need to log in
How to avoid eslint no-param-reassign error in my case?
Hello. The logic is this, I need to update an element in the table, send the data to the server, get the new changed data and want to put it into an array to update it in the table.
this.itemsData.forEach((item) => {
if (item.id === this.selectedItem.id) {
item.name = newItem.name;
item.data = newItem.data;
}
});
Answer the question
In order to leave comments, you need to log in
You are changing the item, and in the eslint settings it is forbidden.
For example I would do this
const item = this.itemsData.find(val => val.id === this.selectedItem.id);
if (item) {
item.name = newItem.name;
item.data = newItem.data;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question