React Typescript:Ant Design Table 重新渲染特定列

React Typescript: Ant Design Table Rerender specific Column

我正在改变我的 datasource 状态 "this.state.question" 但 Table 列 "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 >
   )
}},

从不改变状态。

快速浏览告诉我您的代码应该如下所示:

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
        }
      })
   }))
}