npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@careerday-jobs/react-paginator

v0.1.16

Published

Simple and easy-to-use pagination library for React

Downloads

7

Readme

npm version npm downloads official website

📚 Why react-paginator?

Every web developer should work on pagination at some point. We were using React.js, and surprised by the fact that there is no single package we'd like to just install and start using. If you're using React and going to work on pagination, then react-paginator is a worth trying.

🖥 Screenshots

Mobile

Desktop

📦 Installation

npm install @careerday-jobs/react-paginator

🪄 Basic Usage

// import at the top of file
import { PaginatedParam, usePaginated, PaginatedCommander } from '@careerday-jobs/node-paginator';

// In a React component.
const SampleComponent = () => {

  // 1. Call usePaginated(). Give page size and selectablePageNumberRange.
  const [paginated, setPaginated, drawPaginated, selectablePageNums] = usePaginated(10, 5);

  // 2. Return <PaginatedCommander /> component
  return (
    <>
      <PaginatedCommander
        paginated={paginated}
        setPaginated={setPaginated}
        selectablePageNums={selectablePageNums}
        dataFetchFunction={async (page: number) => {
          const apiResponse = await axios.get('https://myawesomehomepage.com/showitems?page=' + page);
          const totalItemCount = parseInt(apiResponse.data.totalItemCount);

          // 3. Call drawPaginated() everytime page changes.
          const paginatedParam = new PaginatedParam(
            1, // pageNo 
            10, // pageSize
            totalItemCount, // totalItemCount
            5 // selectablePageNumberRange
          );
          
          drawPaginated(paginatedParam);
        }}
      />
    </>
  );
}

🪄 Parameters

usePaginated()

  • pageSize number

    The size of each page.
  • selectablePageNumberRange number

    The range of page numbers you can see. 
    For example, if selectablePageNumberRange is 5, 
    you will see page numbers like 1, 2, 3, 4, 5 when you're on the 1st page.
    And you will see 6, 7, 8, 9, 10 when you're on the 7th page.

PaginatedParam

PaginatedParam constructor requires four parameters like below.

  • pageNo number

    Current page number.
  • pageSize number

  • totalItemCount number

    The number of whole items.
  • selectablePageNumberRange number

PaginatedCommander (React component)

PaginatedCommander component requires four parameters like below.

  • paginated

    paginated variable you got from usePaginated() 
  • setPaginated

    setPaginated variable you got from usePaginated() 
  • selectablePageNums

    selectablePageNums variable you got from usePaginated()
  • dataFetchFunction

    The callback you want to use to fetch data.
    Please note that you should call drawPaginated() function
    after data gets prepared.
  • locale

    For now there are only two locales are supported: 'en' and 'ko'.

🖼️ Styling

Styling can be achieved by just importing css file provided. CDN version will be provided in the future.

/* Example */
@import '@careerday-jobs/react-paginator/lib/paginated.css';

⏳ Pagination Library On Backend

Looking for a library which supports pagination on backend? Why don't you check out node-paginator? It's way more efficient when you try both packages!

👨👩 Contributors

@kunhokimcareerday

@starseeder0309

@hyojin961

🔑 License

MIT @ 2022 CareerDay