2022-03-11
4459
#react
Sampath Gajawada
96445
Mar 11, 2022 â‹… 15 min read

React pagination from scratch using hooks

Sampath Gajawada I'm a full-stack developer who always wishes to implement new and challenging elements in my daily life. Currently, my focus is on React and Vue.

Recent posts:

A Guide To Object.groupBy: An Alternative To Array.reduce

A guide to Object.groupBy: An alternative to Array.reduce

Learn how Object.groupBy and Map.groupBy improve JavaScript data grouping over reduce, with performance benchmarks and comparisons.

Sebastian Weber
Feb 5, 2025 â‹… 4 min read
Best CI/CD tools for React Native

Best CI/CD tools for React Native

Get a high-level comparison of five of the most popular and well-used CI/CD tools for React Native apps, including the features they support.

Hussain Arif
Feb 5, 2025 â‹… 7 min read
chrome dev tools for API mocking

How to use Chrome DevTools for API mocking

API Mocking allows frontend developers to simulate the responses and behaviors of a live API, such as error handling, timeouts, and specific status codes in real time. Chrome DevTools Local Overrides make this even easier.

Emmanuel John
Feb 4, 2025 â‹… 7 min read
How To Implement View Transitions In Multi-Page Apps

How to implement view transitions in multi-page apps

Enhance navigation in multi-page apps using the View Transition API, CSS, and JavaScript — no heavy frameworks needed.

Rob O'Leary
Jan 31, 2025 â‹… 12 min read
View all posts

3 Replies to "React pagination from scratch using hooks"

  1. Hi, This is great article about pagination.
    What if, we wanted to show the button to show last page and first page

  2. Hi, Although the approach for creating pagination is great and easy. I’m bit concerned about what will happen if current page won’t load then we will end up showing current page on UI but with the old data.

    IMHO It would be great if we just set current page once page data is fetched. and in next and previous calls we just increment and decrement current page with a local variable.

  3. There is bug with the code on github
    fetch(`https://api.instantwebtools.net/v1/passenger?page=${currentPage}&size=5`) instead of
    fetch(`https://api.instantwebtools.net/v1/passenger?currentPage=${currentPage}&size=5`)
    in teh file Passenger.js

Leave a Reply