TanStackT
TanStackโ€ข2y agoโ€ข
2 replies
urgent-maroon

defaultColumn not seeing state changes

I'm defining a column renderer using defaultColumn, it works great.

I have some state containing an array of selected rows (selectedRows), and I want to display an <input> if the cell being rendered is in a row within selectedRows. However, when selectedRows changes, the cells are not updating as they should.

I think this might be due to defaultColumn being memoised internally (https://github.com/TanStack/table/blob/main/packages/table-core/src/core/table.ts#L411), but I'm not 100% sure.

I've created a Code Sandbox based on the "Editable Data".

- Selected rows have a [S] after each cell value
- the array of selected rows is displayed at the bottom
- Click "Select extra row" to add a row to selected
- Desired behaviour is for the 4th row values to have [S] after them after adding the extra row

https://codesandbox.io/p/devbox/sleepy-snyder-zkmqm3

Can anyone shed any light on what's going on please? ๐Ÿ™‚
Was this page helpful?