I have a function which I am trying to change the properties of an object inside an array of objects at a particular index:
const handleEdit= (index) =>{
if(itemList[index].edit==true){
const copied=[...itemList];
const item2 = {...itemList[1]};
item2.edit= true;
item2.Name='test';
copied[index]=item2;
setItemList(copied);
console.log("correct",itemList);
}
When I look at the log, the "Name" property properly updates from it's previous value to "test" but the boolean "edit" property stays at it's previous value. What am I doing wrong here?