Shadcdn Table: Unhandled Runtime ErrorTypeError: Cannot read properties of null (reading 'length')
Answered
Jenn posted this in #help-forum
JennOP
<TableBody>
{Array.isArray(table.getRowModel()?.rows) && table.getRowModel()?.rows.length ? (
table.getRowModel().rows.map((row) => (
<TableRow
key={row.id}
data-state={row.getIsSelected() && "selected"}
>
{row.getVisibleCells().map((cell) => (
<TableCell key={cell.id}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
</TableRow>
))
) : (
<TableRow>
<TableCell colSpan={columns.length} className="h-24 text-center">
No results.
</TableCell>
</TableRow>
)}
</TableBody>
Answered by Jenn
Got it solved already 🤣 there was a problem with my types, I was declaring an 'email' on the types when I was not able to include it in my query 🤣🤣
11 Replies
JennOP
@Anay-208
Send the error screenshot here
JennOP
Let me see
Try console.log(table.getRowModel()) just before the array
Check console also for errors
I think it’s a error inside the function getRowModel
Console.log in a useEffect hook
JennOP
Got it solved already 🤣 there was a problem with my types, I was declaring an 'email' on the types when I was not able to include it in my query 🤣🤣
Answer
Mark message as solution