当在 mobx 商店中更改状态时,Ant-Design Table 不呈现 [英] Ant-Design Table not rendering when change state in mobx store

查看:40
本文介绍了当在 mobx 商店中更改状态时,Ant-Design Table 不呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了在 ant design Table 组件中单击行的行为.这应该更改表上的 rowClassName.以下是 CodeSendBox 的示例.当您单击表格行时,Store.selectedRowKey 中的值会发生变化,但表格不会重新呈现.如果将分隔滑块移动到沙箱并且表格大小发生变化,则会发生渲染并应用新的行选择

I program the behavior of clicking on a row in the ant design Table component. This should change the rowClassName on the Table. Here is an example on CodeSendBox. When you click on a table row, the value in the Store.selectedRowKey changes, but the table is not re rendering. If you move the dividing slider to the sandbox and the table size changes, then rendering occurs and a new row selection is applied

这是另一个例子,其中 mobx 不适用于 ant-design Table

Here's another example, where mobx don't work with ant-design Table

Ant Design Table with Modal form CRUD

我是 Mobx 的新手我真的很想了解我做错了什么

I'm new in the Mobx I really want to understand what I'm doing wrong

推荐答案

要重新渲染 Ant-Design 表,您必须将数据源值作为可观察值的副本传递.

To re-render an Ant-Design table, you have to pass the data-source value as a clone of the observable value.

你必须改变

<Table
    columns={columns}
    dataSource={values}
/>

到以下代码:

<Table
    columns={columns}
    dataSource={[...values]}
/>

这篇关于当在 mobx 商店中更改状态时,Ant-Design Table 不呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆