Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant-Design Table not rendering when change state in mobx store

Tags:

reactjs

antd

mobx

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

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

Ant Design Table with Modal form CRUD

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

like image 539
FreeClimb Avatar asked Dec 10 '25 17:12

FreeClimb


1 Answers

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

you have to change

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

to the following code:

<Table
    columns={columns}
    dataSource={[...values]}
/>
like image 139
Nechama Avatar answered Dec 13 '25 07:12

Nechama