This package provides a number of Pagination components that you can use to split huge data sets into smaller data chunks
this hook provides the essential logic needed in managing the state of any pagination use-case.
yarn add @onaio/pagination
UsePagination makes use of the following props
- the total numnber of records to be paginated
- the number of records in a single page
- reducer:(redux-styled reducer function)
- uses the state reducer pattern allowing you take control of state updates logic
- initialState:(< generic >)
- any object passed as an initial state is spread over the default initial state before doing anything else.
Paginator Code example
Here is a code sandbox showing how this hook could be used to create a bootstrap-powered pagination component
- paginationState: the pagination state:
PS: One can override the above exposed variables via the initial state or using their own custom reducer. due to this dynamic nature the pagination state is not guaranteed to always be as shown above.
- nextPage: increments the currentPage counter by one
- firstPage: goes to the first page
- lastPage: goes to the last page
- goToPage: takes to arbitrary page
- previousPage: decrements the currentPage counter by one
- dispatch: The base dispatch method, the above helper functions are wrapper functions around this, use this to dispatch custom actions if any
- canNextPage: can i go to the nextPage?, is there a nextPage?
- canPreviousPage: can i go to the previousPage?, is there a previousPage?