table icon indicating copy to clipboard operation
table copied to clipboard

Cannot read properties of undefined (reading 'getIsSelected') in cell definition

Open isaacfink opened this issue 7 months ago • 0 comments

TanStack Table version

v8.21.3

Framework/Library version

svelte v4 and 5 (with the replacement from https://github.com/dummdidumm/tanstack-table-8-svelte-5)

Describe the bug and the steps to reproduce it

Here is my table definition

const table = createSvelteTable<User>({
    enableRowSelection: true,
    data: users,
    getCoreRowModel: getCoreRowModel(),
    columns: [
      {
        id: "checkbox",
        cell: (props) => {
          console.log(Object.keys(props));
          return renderComponent(Checkbox, {
            checked: props.row.getIsSelected(),
            toggle: props.row.getToggleSelectedHandler(),
          });
        },
        header: ({ table }) => {
          return renderComponent(Checkbox, {
            checked: table.getIsAllRowsSelected(),
            toggle: table.getToggleAllRowsSelectedHandler(),
          });
        },
      },
     // more columns
    ],
  });

I am getting this error when the table is rendered

TypeError: Cannot read properties of undefined (reading 'getIsSelected')
    at cell (/Users/isaac/Desktop/temp/tanstack-table/app/src/routes/+page.svelte:30:32)

typescript doesn't complain so I am assuming the row should be there but it's not, I tried logging props and it doesn't have a row object

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://github.com/isaacfink/tanstack-table-bug-repro

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

Maybe, I'll investigate and start debugging

Terms & Code of Conduct

  • [x] I agree to follow this project's Code of Conduct
  • [x] I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

isaacfink avatar May 22 '25 21:05 isaacfink