The number of pages fully depend on the contentPerPage, the API route I used in the code only returns an array of 20 items so the maximum possible number of pages is either 1 or 20, with 3 contentPerPage it generated 7 pages
So it's not fully functional pagination. Just a simple demo.
Here is example how pagination should work (the code is in PHP but it's algorithm that can be rewritten in any language). gist.github.com/bramus/5d8f2e0269e...
Also note that prev should be disabled when on first page.
It's functional, I was referring to Typescript you were talking about types. There are many ways to implement pagination, this is just my way, and this will work for any language
It's functional, I was referring to Typescript you were talking about types.
I don't quite understand what you write this above comment. I just mean that this is not fully implemented pagination, because it's missing fundamental features. So it can't be used in any real projects. You need to implement the thing yourself if you want to have something that is a full pagination. Also this will not work with any language because it's like half of the implementation.
Added two issues. I may contribute if the issue is not fixed when I will need pagination since I will need something like this in the near future for my application.
The number of pages fully depend on the
contentPerPage
, the API route I used in the code only returns an array of 20 items so the maximum possible number of pages is either 1 or 20, with 3contentPerPage
it generated 7 pagesHere is a working demo => use-pagination.vercel.app/
So it's not fully functional pagination. Just a simple demo.
Here is example how pagination should work (the code is in PHP but it's algorithm that can be rewritten in any language).
gist.github.com/bramus/5d8f2e0269e...
Also note that prev should be disabled when on first page.
It's functional, I was referring to Typescript you were talking about types. There are many ways to implement pagination, this is just my way, and this will work for any language
I don't quite understand what you write this above comment. I just mean that this is not fully implemented pagination, because it's missing fundamental features. So it can't be used in any real projects. You need to implement the thing yourself if you want to have something that is a full pagination. Also this will not work with any language because it's like half of the implementation.
Sorry I thought I replied to another comment, could you list out these features, so I improve this React hook
You are also free to make contributions to the repo
Added two issues. I may contribute if the issue is not fixed when I will need pagination since I will need something like this in the near future for my application.
👍🏽