usePagination
The `usePagination` hook provides advanced pagination state management with a simple and intuitive API.
usePagination Hook
Usage
Example
Here's an example showing dynamic page size selection using the usePagination
hook:
Dynamic Page Size
Pagination with adjustable items per page
Items per page:
Showing 5 items
API Reference
Hook Parameters
Return Value
The hook returns a tuple containing the pagination state and actions:
State Properties
Property | Type | Description |
---|---|---|
currentPage | number | Current active page number |
pageSize | number | Number of items per page |
totalItems | number | Total number of items |
totalPages | number | Total number of pages |
startIndex | number | Start index of current page items |
endIndex | number | End index of current page items |
hasNextPage | boolean | Whether there is a next page |
hasPreviousPage | boolean | Whether there is a previous page |
Actions
Method | Parameters | Description |
---|---|---|
setCurrentPage | (page: number) | Set the current page number |
setPageSize | (size: number) | Set the number of items per page |
nextPage | - | Go to the next page |
previousPage | - | Go to the previous page |
firstPage | - | Go to the first page |
lastPage | - | Go to the last page |
reset | - | Reset to initial state |
Last updated on