DEV Community

Discussion on: Pagination in Javascript and React, with a custom usePagination() hook

Collapse
 
damiisdandy profile image
damilola jerugba • Edited

Hi Everyone, I've noticed most of you guys are requesting for features like the ability for the repo to handle more than 1000 pages, the usePagination() hook can handle ∞ number of pages. But you guys are should understand that this blog post is simply to show the usePagination() hook and has nothing to do with the pagination buttons or styling. Some of you are requesting that I should add the UI functionality of ... in the middle of the pagination buttons for pages that are as large as a 100 pages. This require for the usePagination() hook to also return a component that contains the pagination buttons.

If you'd like me to implement this, please get the github repo to 50 stars and i'll convert this into a full library that tackles these issues and more.

You are also free to collaborate on this repo so we can build it as a library together πŸ’™

Thank you πŸ’™πŸ’™πŸ’™πŸ’™

Collapse
 
mbrookes profile image
Matt

Here's a fully functional usePagination hook, with a demo of rendering buttons and an ellipsis: mui.com/components/pagination/#use...

Collapse
 
damiisdandy profile image
damilola jerugba

That’s great, but you’ll need install the β€˜@mui’ library to use it

Thread Thread
 
mbrookes profile image
Matt

Well, sure, but that's a single command (yarn add or npm install). And since all you import is the hook, that's all that will be included in your bundle.

Thread Thread
 
damiisdandy profile image
damilola jerugba

I'll try that, but I'll still challenge myself and create a npm package, it will be my first open source project

Thread Thread
 
mbrookes profile image
Matt

Of course! And perhaps you’ll find a more elegant implementation. It’s a tricky problem to solve! Good luck! πŸ‘