T
TanStack2y ago
rival-black

TypeError: Cannot read properties of undefined (reading 'length') at accessRows

I'm sure that I'm passing table data that is not empty but I still get this error. Does anyone encounter this problem? I'm using Remix.btw const categories = [ { id: "1", version: 1, status: SimpleStatus.ACTIVE, categoryName: "pasta", branchId: "12", businessId: "13", createdAt: new Date(), createdBy: "Ad", updatedAt: new Date(), updatedBy: "Ad", }, { id: "2", version: 1, status: SimpleStatus.ACTIVE, categoryName: "pasta", branchId: "12", businessId: "13", createdAt: new Date(), createdBy: "Ad", updatedAt: new Date(), updatedBy: "Ad", }, ] as Category[]; console.log(categories.length); // it logs 2 const table = useReactTable({ categories, columns, getCoreRowModel: getCoreRowModel(), }); TypeError: Cannot read properties of undefined (reading 'length') at accessRows (file:///.../node_modules/@tanstack/table-core/src/utils/getCoreRowModel.ts:31:44)
3 Replies
rival-black
rival-blackOP2y ago
Solved my problem by renaming categories to data. I don't know why that works. Anyone care to explain?
fascinating-indigo
fascinating-indigo2y ago
you have to pass data to the table.
const table = useReactTable({
data: categories,
columns,
getCoreRowModel: getCoreRowModel(),
});
const table = useReactTable({
data: categories,
columns,
getCoreRowModel: getCoreRowModel(),
});
is what you need.
rival-black
rival-blackOP2y ago
Thanks for this.

Did you find this page helpful?