您好,我無法在反應(yīng)中更新嵌套對(duì)象狀態(tài)。當(dāng)我嘗試這樣做時(shí),我在所有孩子中都遇到了錯(cuò)誤(來自父母的未定義道具)。這是我的代碼: updateColumn(newSubject,dayId,order){ console.log("tu som"); console.log(newSubject); console.log(dayId); console.log(order); console.log(this.state.schedule); //Problematic part: let newSchedule = this.state.schedule; newSchedule.days[dayId].slots[order] = newSubject; console.log("newSchedule"); console.log(newSchedule); this.setState({schedule:this.state.schedule}); console.log("this new state"); console.log(this.state.schedule); //State changed but error shows }
使用變量標(biāo)識(shí)符反應(yīng)更新嵌套對(duì)象的狀態(tài)
蝴蝶刀刀
2022-06-09 19:34:40