I have a state called this.state.devices which is an array of device objects.
Say I have a function
updateSomething: functi
I solve it doing a array splice in object I wish modify, before update component state and push of object modified again.
Like example below:
let urls = this.state.urls;
var index = null;
for (let i=0; i < urls.length; i++){
if (objectUrl._id == urls[i]._id){
index = i;
}
}
if (index !== null){
urls.splice(index, 1);
}
urls.push(objectUrl);
this.setState((state) => {
return {urls: urls}
});