T
TanStack3y ago
ambitious-aqua

Simple tanstack table example with (faker.js data) returns Cannot read properties of undefined

So I'm following the example from: https://tanstack.com/table/v8/docs/examples/svelte/sorting with a few alternations, mainly instead of Person I'm using my own fake data. I load it in via:
const tableData = makeLinkData(100);
const tanTableOptions = writable({
tableData,
columns,
state: { sorting },
onSortingChange: setSorting,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
debugTable: true
});
const tanTable = createSvelteTable(tanTableOptions);
const tableData = makeLinkData(100);
const tanTableOptions = writable({
tableData,
columns,
state: { sorting },
onSortingChange: setSorting,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
debugTable: true
});
const tanTable = createSvelteTable(tanTableOptions);
However if I use: <div>{$tanTable.getRowModel()}</div> I'll get the error: Cannot read properties of undefined (reading 'length')
Svelte Table Sorting Example | TanStack Table Docs
An example showing how to implement Sorting in Svelte Table
1 Reply
ambitious-aqua
ambitious-aquaOP3y ago
Nevermind: Didn't see that {data: <variable_name} is required if no variable is named data

Did you find this page helpful?