How Javascript/React/Angular OnChange works while iterating through a map
Hi Coders, sometimes it's annoying that small things take much of your time, just like handling the Onchange operation of multiple value while iterating through the map, well I got your back, let's roll the code:
Suppose you have data and you want to change the specific value in the data then you have to put the particular unique index to the onChange function of yours
let's assume,
let Data =[{id:1, name:”Batman”},{id:1, name:”Superman”},{id:1, name:”Ironman”}]
So your onChange function is be like :
function handleChange(e,index)
{ newData= […data];
newData[index]={…newData[index],[e.target.id]:e.target.value}
console.log(newData) //you will have the new changed data
}