T
TanStack•3y ago
xenial-black

How to handle the row deselection on onRowSelectionChange (using zustand)?

Hi, all the example in the docs use React state and just directly pass the setState to onRowSelectionChange I'm using zustand to manage state and this is what I came up with
selectedLinks: {
1: true,
},
setSelectedLinks: (obj, ...args) => {
set((state) => {
state.dataSource.selectedLinks = {
...state.dataSource.selectedLinks,
...obj(),
};
});
}
selectedLinks: {
1: true,
},
setSelectedLinks: (obj, ...args) => {
set((state) => {
state.dataSource.selectedLinks = {
...state.dataSource.selectedLinks,
...obj(),
};
});
}
// DataTable.tsx
const table = useReactTable({
data,
columns,
enableRowSelection: true,
getCoreRowModel: getCoreRowModel(),
state: {
rowSelection,
},
onRowSelectionChange,
});
// DataTable.tsx
const table = useReactTable({
data,
columns,
enableRowSelection: true,
getCoreRowModel: getCoreRowModel(),
state: {
rowSelection,
},
onRowSelectionChange,
});
Now I expected if I deselect a row I'd get the index value as false so but that's not the case, how do I handle the Deselection?
2 Replies
xenial-black
xenial-blackOP•3y ago
This is almost 1 week old. Can somebody please help me out here? cc @Austin Condiff @Tanner Linsley 🥺
mere-teal
mere-teal•3y ago
Obj is an updater that takes the precious value. You’re not passing the precious value to it?

Did you find this page helpful?