I'm using a react component that need me to pass in below prop
<Pager
totalPages={10}
currentPage={1}
/>
I can't figure out the calculation as in the api I have total_items
, not totalPages
. if I have 50 total_items
, how can I produce 5 for the totalPages
prop? says my limit is 10.
Divide total_items
by limit
, and round the value up.
Math.ceil(total_items/limit);
50 items / 10 per page = 5 pages
55 items / 10 per page = 6 pages
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With