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? 🙂2 Replies
harsh-harlequin•16mo ago
Are you sure it's not as simple as forgetting to include relevant state in the column defs dependency array in your own code?

absent-sapphireOP•16mo ago
Oh man, great spot! That fixed it. Thank you so much for that, I really appreciate it 🙂