Skip to content

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

@isaacfink

Description

@isaacfink

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

  • I agree to follow this project's Code of Conduct
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions