this.state = {
list:[
{
id:1,
name:"list1",
editing:false
},
{
id:2,
name:"list2",
editing:false
},
{
id:3,
name:"list3",
editing:false
}
]
}
handleClick=(id)=>{
for(let i=0;i<this.state.list.length;iPP){
if (this.state.list[i].id===id){
this.state.list[i].editing=true
break
}
}
this.setState({
list:this.state.list
})
}
for example, to modify how id=1 "s editing=true is written elegantly, the for loop I wrote looks very low.
.