在Mobx存储中更改状态时无法呈现Ant-Design Table [英] Ant-Design Table not rendering when change state in mobx store

查看:254
本文介绍了在Mobx存储中更改状态时无法呈现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不适用于蚂蚁设计表

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

模态形式为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天全站免登陆