我在我的組件中使用 Formik,其中使用如下方法調用addMetadata(values) { console.log(values); let newState = update(this.state, { pro: { $set: values} }); console.log(newState); // this point result print as expected this.setState(newState); console.log(this.state); // but here state not showing update result }我的狀態看起來像this.state = { pro: { key1: '', key2: [] key3: {} }}但是狀態沒有更新,有人知道為什么嗎?
使用不變性幫助程序更新功能不更新反應狀態
偶然的你
2022-06-16 10:25:13