@flying-studio/use-pagination
![npm version](https://camo.githubusercontent.com/3028882d010336f61e7364a7932260007c1f59902719f6ec513138eb0aaa5622/68747470733a2f2f62616467652e667572792e696f2f6a732f40666c79696e672d73747564696f2532467573652d706167696e6174696f6e2e737667)
import usePagination from "@flying-studio/use-pagination";
const { data, loading, error, run, refresh, fetchData } = usePagination(
(currPage) => request(currPage)
);
npm i @flying-studio/use-pagination
yarn add @flying-studio/use-pagination
pnpm add @flying-studio/use-pagination
declare const usePagination: <T>(paginationRequest: (currPage: number) => Promise<T[]>, option?: {
idPropertyName: string;
initialPage: number;
beforeAllRequest: (currPage: number) => number;
afterAllRequest: (list: T[]) => void;
} | undefined) => {
data: T[];
loading: boolean;
error: boolean;
run: (currPage?: number) => void; // with page++
refresh: () => void; // reload the list with page 1
fetchData: (type: string) => Promise<{
id: any;
item: T;
}[] | undefined>;
};