fn
useOffsetPagination
v0.0.1testeddemoA composable function that provides pagination functionality for offset based pagination
Examples
ts
const {
currentPage,
currentPageSize,
totalPages,
isFirstPage,
isLastPage,
next,
previous,
select,
} = useOffsetPagination({ total: 100, pageSize: 10, page: 1 });ts
const {
currentPage,
} = useOffsetPagination({
total: 100,
pageSize: 10,
page: 1,
onPageChange: ({ currentPage }) => console.log(currentPage),
onPageSizeChange: ({ currentPageSize }) => console.log(currentPageSize),
onTotalPagesChange: ({ totalPages }) => console.log(totalPages),
});Demo
Loading demo…
Signatures
ts
export function useOffsetPagination(options: Omit<UseOffsetPaginationOptions, 'total'>): UseOffsetPaginationInfinityReturn;ts
export function useOffsetPagination(options: UseOffsetPaginationOptions): UseOffsetPaginationReturn;Parameters
| Parameter | Type | Description |
|---|---|---|
options | UseOffsetPaginationOptions | The options for the pagination |
Returns
UseOffsetPaginationReturnThe pagination object| Property | Type | Description |
|---|---|---|
currentPage | WritableComputedRef<number> | — |
currentPageSize | WritableComputedRef<number> | — |
totalPages | ComputedRef<number> | — |
isFirstPage | ComputedRef<boolean> | — |
isLastPage | ComputedRef<boolean> | — |
next | VoidFunction | — |
previous | VoidFunction | — |
select | (page: number) => void | — |