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:

what's new in next js 15.4

Next.js 15.4 is here: What’s new and what to expect

Next.js 15.4 is here, and it’s more than just a typical update. This version marks a major milestone for the framework and its growing ecosystem.

Abiola Farounbi
Jul 29, 2025 â‹… 6 min read
React logo over a dark blue abstract background with glowing network nodes and connections

Build interactive React UIs for LLM outputs using llm-ui

If you’re building an LLM-powered application, llm-ui is a powerful tool to help you add structure, flexibility, and polish to your AI interfaces.

Emmanuel John
Jul 29, 2025 â‹… 9 min read
How I Debug Faster With These Chrome DevTools Console Features

How I debug faster with these Chrome DevTools Console features

Improve the old-fashioned debugging JavaScript workflow by effectively using some lesser-known Chrome DevTools console features.

Shalitha Suranga
Jul 28, 2025 â‹… 9 min read
Catch Frontend Issues Before Users Using Chaos Engineering

Catch frontend issues before users using chaos engineering

This article covers how frontend chaos engineering helps catch UI and UX issues before users experience them using tools like gremlins.js.

Muhammed Ali
Jul 25, 2025 â‹… 5 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