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:

Build A Custom React Native Turbo Module For Android

Build a custom React Native Turbo Module for Android

Build a React Native Turbo Module for Android to access device info like model, IP, uptime, and battery status using native mobile APIs.

Emmanuel John
Feb 27, 2025 â‹… 8 min read
how to measure round-trip time using cURL

How to measure round-trip time (RTT) using cURL

Learn how to measure round-trip time (RTT) using cURL, a helpful tool used to transfer data from or to a server.

David Omotayo
Feb 26, 2025 â‹… 10 min read

React.memo explained: When to use it (and when not to)

React.memo prevents unnecessary re-renders and improves performance in React applications. Discover when to use it, when to avoid it, and how it compares to useMemo and useCallback.

Emmanuel John
Feb 26, 2025 â‹… 9 min read
React useCallback: When And How To Use It For Better Performance

React useCallback: When and how to use it for better performance

Learn how React’s useCallback hook boosts performance by memoizing functions and preventing unnecessary re-renders with practical examples and best practices.

Emmanuel John
Feb 26, 2025 â‹… 6 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