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

@tshio/react-router-pagination

v1.2.1

Published

[![Build Status](https://travis-ci.org/TheSoftwareHouse/react-router-pagination.svg?branch=master)](https://travis-ci.org/TheSoftwareHouse/react-router-pagination) [![Code Coverage](https://codecov.io/gh/TheSoftwareHouse/react-router-pagination/branch/mas

Downloads

5

Readme

Status

Build Status Code Coverage License Version

react-router-pagination

Installation

Using yarn:

$ yarn add @tshio/react-router-pagination

Using npm:

$ npm install --save @tshio/react-router-pagination

Usage

In order to connect custom component with pagination, it is required to import withRouter function from react-router-dom and use it to wrap connectRouterWithPagination function.

At the beginning, wrap your list component using connectRouterWithPagination function in your container:

import { withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import { compose } from 'redux';

import { connectRouterWithPagination } from '@tshio/react-router-pagination';

import { fetchUsers } from '../redux/users/users.actions';
import { ListComponent } from '../list.component';
import { PaginationComponent } from '../pagination.component';

const mapStateToProps = () => ({ ... })

const mapDispatchToProps = dispatch => ({
    onPageChange: (params) => dispatch(fetchUsers(params)) // `onPageChange` method will dispatch your redux action when page changes
});

//And now, connect your store with list component

export const ListContainer = compose(
  withRouter,
  connect(mapStateToProps, mapDispatchToProps),
  connectRouterWithPagination(PaginationComponent,
    // In first parameter pass your custom pagination component
    {
        // Second parameter (optional) is an object and allow you to pass config options
        pageChangeCallbackKey: "pageChangeCallback",
        currentPageKey: "page",
        pageParamName: "usersListPage",
        itemsPerPageParamName: "itemsNumber",
        defaultItemsPerPage: 8
        // See list of available options below..
    }
  )
)(ListComponent);

Keep in mind, that onPageChange function is required and always has to be implemented!

And then, you can render pagination component in list component:

import React, { Component } from 'react';

// ...

export class ListComponent extends Component {
  render() {
    return (
      <div>
        // ...
        {this.props.pagination({
          // here, you can define custom properties for pagination component
        })}
      </div>
    );
  }
}

This package is working with page and itemsPerPage parameters which are included in URL. If page param is missing, it will be set as default with value 1. If itemsPerPage param is missing, it will be initialized with value of defaultItemsPerPage from config options or with value of 10.

Config options

| Option name | Default value | Type | Role | | --------------------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------ | | currentPageKey | currentPage | string | Name of prop which is passed to pagination component to point on current page. | | pageChangeCallbackKey | onChange | string | Name of callback function which is called when you click on navigation button in pagination component. | | pageParamName | page | string | Determines what is the name of page param which is displayed in URL; e.g. /users?page=1. | | itemsPerPageParamName | itemsPerPage | string | Determines what is the name of items per page param displayed in URL; e.g. /users?itemsPerPage=10 | | defaultItemsPerPage | 10 | number | Determines initial and default value of number of items per page. |

Development

We welcome all contributions. Please read our CONTRIBUTING.md first. You can submit any ideas as GitHub issues.