1.0.4 • Published 7 years ago

tn-pagination v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

pagination

Coverage Status npm version

A SEO friendly pagination component for React.

Install

Via NPM

npm install tn-pagination

Usage

import React from 'react';
import Pagination from 'tn-pagination';

class MyComponent extends React.Component {
  componentDidMount() {
    // fetch data for the first time render.
  }

  componentWillReceiveProps(nextProps) {
    // fetch data when click the pagination.
  }

  genUrl = (page) => `/page/${page}`;

  render() {
    return (
      <div>
        <h1>Item list</h1>
        ... //list of items
        <Pagination
          pageCount={15}
          pageRangeDisplayed={5}
          page={1}
          genUrl={this.genUrl}
        />
      </div>
    );
  }
}

Props

List of props that can pass into the components.

PropsTypeRequiredDefaultDescription
pageCountIntegertrue-Number of total Pages
pageRangeDisplayedIntegertrue-Range that pagination display
genUrlFunctiontrue-Function for generate url to attach in the pagination link
pageIntegerfalse1Number of current page
firstLabelStringfalse'\xAB'Label for the first page button
previousLabelStringfalse'\u2039'Label for the previous page button
nextLabelStringfalse'\u203A'Label for the next page button
lastLabelStringfalse'\xBB'Label for the last page button
containerClassNameStringfalse'pagination'Classname of the pagination component
activeClassNameStringfalse'active'Classname of the current page button
pageClassNameStringfalse'page'Classname of the button excluded first/previous/next/last button
pageLinkClassNameStringfalse'page-link'Classname of the link in the button excluded first/previous/next/last button
firstClassNameStringfalse'first'Classname of the first button
firstLinkClassNameStringfalse'first-link'Classname of the link in the first button
previousClassNameStringfalse'previous'Classname of the previous button
previousLinkClassNameStringfalse'previous-link'Classname of the link in the previous button
nextClassNameStringfalse'next'Classname of the next button
nextLinkClassNameStringfalse'next-link'Classname of the link in the next button
lastClassNameStringfalse'last'Classname of the last button
lastLinkClassNameStringfalse'last-link'Classname of the link in the last button