mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 21:20:57 +00:00
26 lines
515 B
TypeScript
26 lines
515 B
TypeScript
import { PaginationState } from "@tanstack/react-table";
|
|
import { useState } from "react";
|
|
|
|
export const usePagination = ({
|
|
pageSize,
|
|
pageIndex,
|
|
}: {
|
|
pageSize?: number;
|
|
pageIndex?: number;
|
|
} = {}) => {
|
|
const [pagination, setPagination] = useState<PaginationState>({
|
|
pageIndex: pageIndex ?? 0,
|
|
pageSize: pageSize ?? 10,
|
|
});
|
|
|
|
const setPage = (pageIndex: number) => {
|
|
setPagination((prev) => ({ ...prev, pageIndex }));
|
|
};
|
|
|
|
return {
|
|
pagination,
|
|
setPagination,
|
|
setPage,
|
|
};
|
|
};
|