我改變了我的datasource狀態,"this.state.question"但表列"Actions"不會重新呈現。
this.setState(currentState => ({
...currentState,
question: currentState.question.map((item) => {
if (item.no !== data.item1.no) return item;
return {
...item,
...data.item1
}
})
}))
應該改變的列:
{ title: "Actions", render: (record: ModelClass) => {
return (
<Space>
<Button
type="primary"
disabled={record.deactivated} //<- nothing happens
/>
</Space >
)
}},
uj5u.com熱心網友回復:
永遠不要改變狀態。
快速瀏覽告訴我你的代碼應該是這樣的:
if (this.state.responseMessage.successful) {
this.setState(currentState => ({
...currentState,
question: currentState.question.map((q) => {
if(q.no !== data.item1.no) return q;
return {
...q,
...data.item1
}
})
}))
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/396298.html
標籤:javascript 反应 打字稿 蚂蚁
