();
+ const { isPending, data } = useQuery({
+ queryKey: ["transactions", pagination.pageIndex],
+ queryFn: () => loader(pagination.pageIndex),
+ placeholderData: keepPreviousData,
+ });
+
+ const table = useReactTable({
+ columns,
+ data,
+ getCoreRowModel: getCoreRowModel(),
+ // getPaginationRowModel: getPaginationRowModel(), // not needed for server-side pagination
+ manualPagination: true,
+ // rowCount: , // TODO: get this from the server
+ pageCount: -1,
+ onPaginationChange: setPagination,
+ state: {
+ pagination,
+ },
+ });
+
+ if (isPending) {
+ return Loading...
;
+ }
return (
-
-
-
- | date |
- description |
- value |
-
-
-
- {data.map((t) => (
-
- | {t.date} |
- {t.description} |
- {t.value} |
-
- ))}
-
-
+ <>
+
+
+ {table.getHeaderGroups().map((headerGroup) => (
+
+ {headerGroup.headers.map((header) => (
+ |
+ {header.isPlaceholder
+ ? null
+ : flexRender(
+ header.column.columnDef.header,
+ header.getContext()
+ )}
+ |
+ ))}
+
+ ))}
+
+
+ {table.getRowModel().rows.map((row) => (
+
+ {row.getVisibleCells().map((cell) => (
+ |
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
+ |
+ ))}
+
+ ))}
+
+
+
+
+
+
+
+
+ Page {table.getState().pagination.pageIndex + 1}
+ >
);
}