Skip to content
Advertisement

Antdesign table not rerendering on new column values

I am having trouble rerendering the columns of my table, the library i am using is ant design and I am trying to create a feature where I reorder the column of the table on demand.

I have created an example the issue here: https://replit.com/@coupacoupa/Ant-Design-column-reordering

In the example, I created a simple button that changes the order of the column which changes a div showcasing the state changed, but in the ant design table, the column doesn’t change.

Below is a snipplet of the way I change the state

JavaScript

Advertisement

Answer

The sort() method sorts the elements of an array in place and returns the reference to the same array, now sorted. But you should pass a new array into setOrderedColumn to rerender

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement