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-data-pagination

v1.0.5

Published

A customisable pagination component for ReactJS

Downloads

22

Readme

react-data-pagination

A customisable pagination component for ReactJS

Installation

npm install --save react-data-pagination

Basic Usage

import Data from 'react-data-pagination';

//this component renders the heading part of your data, your <thead></thead> in the case of a table
const DataContainer = () => {
    return(
        <thead>
            <tr>
                <th>Name</th>
                <th>Address</th>
            </tr>
        </thead>
    );
};

//this component renders the list of data... the table body
//use something unique for your map keys.
const DataList = (props) => {
    const dataset = props.dataset;
    return(
        <Fragment>
            <tbody>
                {dataset.map((value)=>{
                    return(
                        <tr key={value.name}> 
                            <td>{value.name}</td>
                            <td>{value.address}</td>
                        </tr>
                    );
                })}
            </tbody>
        </Fragment>
    );

};

//the dataset
const dataset = [
        {"name": "Curran Barrett", "address": "Ap #177-391 Velit. Ave"},
        {"name": "Vernon Hardy", "address": "480-9044 Aliquam St."},
        {"name": "Baxter Payne", "address": "P.O. Box 795, 139 Nec, Rd."},
        {"name": "Jack Blankenship", "address": "451 Vivamus Av."},
        {"name": "Jordan Christensen", "address": "507-7644 Gravida Rd."},
        {"name": "Luke Kirkland", "address": "Ap #930-4518 Enim. Av."},
        {"name": "Gray Phillips", "address": "5936 Nec, Road"},
        {"name": "Nolan Kramer", "address": "P.O. Box 649, 9887 Donec Ave"},
        {"name": "Marsden Mcmahon", "address": "P.O. Box 603, 8397 Et Av."},
        {"name": "Hashim Riddle", "address": "P.O. Box 341, 1922 Interdum. St."},
        {"name": "Reece Irwin", "address": "595-9942 Est, St."},
        {"name": "Demetrius Sparks", "address": "899-6946 Sed, St."},
        {"name": "Hilel Finch", "address": "1430 Eleifend Av."},
        {"name": "Brenden Owens", "address": "Ap #298-9226 Augue Rd."},
        {"name": "Alec Long", "address": "564-4129 Purus. Av."}
];

<Data
  dataset={dataset}
  offset={0}
  rows={5}
  dataBody={DataContainer}
  dataList={DataList}
  wrapper="table"
  wrapperCssClass="striped"
  buttonCssClass="button"
/>

Props Explained

dataset: An array of objects that form your dataset.

offset: The position in the array you want the first page to start from. Usually left as 0 (zero)

rows: The number of rows per page

dataBody: User created component that will render table headings, if the dataset will be display in a table. This can be set to null if a table is not being used to display the data. Ensure you specify your own table headings. In the case of a table, this component will render your section. See the DataContainer component in the basic example above.

dataList: User created component that will render the data list per page. The dataset is passed as a prop to this component and can be accessed through props.dataset. You can then map() through the dataset to render them. In the case of a table this component will render your section. See the DataList component in the basic example above.

wrapper: The wrapping HTML tag for your data. In the case of a table, this is going to be "table"

wrapperCssClass: css class to assign to the wrapper, for styling.

buttonCssClass: css class to assign to the buttons that will hold the page numbers.

Example Demo With Code

https://codesandbox.io/s/beautiful-beaver-qklbw