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

react-pagination-master

v2.2.5

Published

A very useful and efficient pagination library for React-Spa websites that shows data without refreshing the page

Downloads

40

Readme

Hi there 👋 I'm Mohammad Hossein 👨‍💻

Next Js expert and FrontEnd Developer

Description Library

Library ■ A very useful and efficient pagination library for React-Spa websites that shows data without refreshing the page

It is very compact and optimized and has only 2 dependencies, both react and react-dom.

Without refreshing the page, the products shown and the URL changes

The way the package works is that first you enter all the data you need and the number of data you want on each page and leave the rest of the work to the package ☻

High personalization capabilities such as color, background, visibility or lack of auxiliary arrows, etc.

One of the most interesting and useful features of this library is that if you have 3 pages for your products، you have 3 boxes for pagination. Let's say your site's route to display products is all-Datas/page/1 If the user manually tries to change 1 to 0 or less or greater than 3, it will automatically be redirected to page 1.

In addition، if you have 1 product page، you won't be shown pagination in the DOM of your project، but the URL logic is if it is all-courses/page/1، although pagination is not shown، but if the user wants to move the number 1 higher or lower، the library itself will redirect the user to page 1، and that's the authority of this library.

NOTE 📝 This library is for React language only.

View of the Library

Usage

  • Import the pagination component first.
import Pagination from 'react-pagination-master'
  • Then enter these essential items to launch pagination
<Pagination
    arrDatas={allDatas}
    countDataPerPage={3}
    pathName={'/all-courses/page/'}
    onFilterDatas={handleFilterArrDatas}
/>
  • format your datas. Of course، using useState is optional you only need to format the information you send must be the object in the array format.
const [allDatas, setAllDatas] = useState([
    {id:1, ...},
    {id:2, ...},
    {id:3, ...},
    {id:4, ...},
])

Example

import React, { useState, useEffect } from 'react'
import Pagination from 'react-pagination-master'

export default function Test() {

    const [allDatas, setAllDatas] = useState([])
    const [filterDataPage, setFilterDataPage] = useState([])

    useEffect(() => {
        fetch(`http://localhost:3000/v1/datas`)
            .then(res => res.json())
            .then(datas => setAllDatas(datas))
    }, [])

    const handleFilterArrDatas = datas => setFilterDataPage(datas)

    return (
        <section>
            <div>
                {
                    filterDataPage.map((datas, index) => (
                        <Course key={index} {...datas} />
                    ))
                }
            </div>

            <div>
                { allDatas.length &&
                    <Pagination
                        arrDatas={allDatas}
                        countDataPerPage={3}
                        pathName={'/all-Datas/page/'}
                        onFilterDatas={handleFilterArrDatas}
                    />
                }
            </div>
        </section>
    )
}

Uses Props The Pagination

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | arrDatas | Array | Required. Array of products or anything else | | countDataPerPage | Number | Required. On each page you want to show multiple items | | pathName | String | Required. The URL that your product is located in. | | onFilterDatas | Function | Required. Returns a function that contains data on that page، such as page 4. | | isArrowsShow | Boolean | Optional. Auxiliary arrows for switching between pages | | separateBox | Boolean | Optional. I mean, with... Spaces between page 1 and 4 | | directionPage | String | Optional. direction pagination rtl or ltr. by default ltr | | bgColor | String | Optional. Background-Color of all boxes. | | bgColorActive | String | Optional. The background color of the box of that active page | | color | String | Optional. Color of all boxes. | | colorActive | String | Optional. Text Color Box of the active page |


Social Network