Hello Everyone i'm stuck on this issue i want too update state my data is in this form, when i update the state it removes everything from the state i dont know how can i achieve this please help Sample code
appoinments:[ {
date: "2021-06-04",
id: 12,
app_type: 2,
section: 4,
title: "PZR 60",
patient: "Gerber, Susanna",
pat_nr: 27,
behandler: "Greifenberg, Wolfgang",
zimmer: "Prophylaxe",
kategorie: "Bestell-Patient",
von_min: 720,
bis_min: 780,
color: "#FFF2CC",
border_color: "#006666",
badge_color: "hsl(200, 50%, var(--hsL45))",
vorbereitung: 0,
nachbereitung: 0,
},
{
date: "2021-06-05",
id: 13,
app_type: 2,
section: 4,
title: "PZR 60",
patient: "Gerber, Susanna",
pat_nr: 27,
behandler: "Greifenberg, Wolfgang",
zimmer: "Prophylaxe",
kategorie: "Bestell-Patient",
von_min: 720,
bis_min: 780,
color: "#FFF2CC",
border_color: "#006666",
badge_color: "hsl(200, 50%, var(--hsL45))",
vorbereitung: 0,
nachbereitung: 0,
},
],`
i want to update only
section: 3,
von_min : 433,
bis_min : 234,
date : new date()
I'm using the following approch to update but didn't succeed please help
this.setState(prevState => ({
calendar: { // object that we want to update
...prevState.calendar,
appointments:{
section: params.section,
von_min : params.newFrom,
bis_min : item.von_min + length,
date : date_string
}, // keep all other key-value pairs
// update the value of specific key
}
}))