Next.js Discord

Discord Forum

Shadcdn Table: Unhandled Runtime ErrorTypeError: Cannot read properties of null (reading 'length')

Answered
Jenn posted this in #help-forum
Open in Discord
Avatar
<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 🤣🤣
View full answer

11 Replies

Avatar
@Anay-208
Avatar
Send the error screenshot here
Avatar
Image
Avatar
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
Avatar
It says that:
Type 'void' is not assignable to type 'ReactNode'.ts(2322)
Image
Avatar
Console.log in a useEffect hook
Avatar
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
Avatar
Mark message as solution