0

I have a state as,

 this.state = {
tempData: [{
        "data": [{"id": "a1", "seatNo": 0},{"id": "a2", "seatNo": 0}],
        "rowName": "a",
    },{
        "data": [{"id": "b1", "seatNo": 0},{"id": "b2", "seatNo": 0}],
        "rowName": "b",
    }]}

I want to update the value of specific seatNo with its id on an event.

Shrutika
  • 1
  • 4

1 Answers1

0

try updating state in custom event like this

onclickevent=(eventid)=>{
   let data=[...this.state.tempData]
   data.map(el=>{
   el.data.map(al=>{
       if(al.id===eventid){
        al.seatNo="update the seat number"
       }
   return null
    })
    return null
    })
   this.setState({tempData: data})
}
Kesav
  • 151
  • 4