Skip to content

Commit 7b4b03e

Browse files
Changes
1 parent 94e9685 commit 7b4b03e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/ui/data-table.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export function DataTable<T extends Record<string, any>>({
200200

201201
// Sort rows
202202
const sortedRows = React.useMemo(() => {
203+
if (!filteredRows || !Array.isArray(filteredRows)) return [];
203204
if (!orderBy) return filteredRows;
204205

205206
return [...filteredRows].sort((a, b) => {
@@ -214,10 +215,9 @@ export function DataTable<T extends Record<string, any>>({
214215
}, [filteredRows, order, orderBy]);
215216

216217
// Paginate rows - with safety check
217-
const paginatedRows = sortedRows?.slice(
218-
page * rowsPerPage,
219-
page * rowsPerPage + rowsPerPage
220-
) || [];
218+
const paginatedRows = Array.isArray(sortedRows)
219+
? sortedRows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
220+
: [];
221221

222222
// Show action column if any action handler is provided
223223
const showActions = !!(onEdit || onDelete || onView);

0 commit comments

Comments
 (0)