npm i react-hyper-pagination
In this package, there are some hooks for pagination:
-
useAfterKeyPagiantion
It works with "after key" and it's a cursor-based pagination. It's useful when you need to load more data after the end of a list. For example, you have a list of messages in a chat and you need to load more messages when you scroll to the top of the list. Or you have to use a cursor-based pagination and you want to go to the next or previous pages.- Fetch a new page when
afterKey
changes. - Call
onAfterKeyReceived
when you receive the newafterKey
from the back-end.
- Fetch a new page when
-
useSlicePagination
If you have a list of items you want to slice into pages, you can use this hook. It's useful when you have all data on the client side and you want to slice it into pages. -
useHyperPagination
It combinesuseAfterKeyPagiantion
anduseSlicePagination
. It's useful when you have a cursor-based pagination from the back-end that loads many items in pages and you want to slice the data into small pages on the front-end.- Fetch a new super page (cursor-based pagination) when
superAfterKey
changes. - Call
superOnAfterKeyReceived
andsetSuperItems
when you receive the newafterKey
and "items" from the back-end. - Show
microCurrentPageItems
to the user.
- Fetch a new super page (cursor-based pagination) when
- Add
useOffsetLimitPagination
- Add some examples for the hooks
WTFPL