2.0.0 • Published 5 years ago

react-pagination-js v2.0.0

Weekly downloads
232
License
MIT
Repository
github
Last release
5 years ago

react-pagination-js

travis build

Simple and light weight pagination for react. This library is updated version of react-pagination-library. It comes with five themes and are easy to customize. 1. default 2. dark 3. bootstrap 4. border-bottom 5. circle

Demo

Example

click here for live demo.

Installation

$ npm install react-pagination-js

Usage

import React from "react";
import Pagination from "react-pagination-js";
import "react-pagination-js/dist/styles.css"; // import css

class App extends React.Component {
  state = {
    currentPage: 1
  };
  changeCurrentPage = numPage => {
    this.setState({ currentPage: numPage });
    //fetch a data
    //or update a query to get data
  };
  render() {
    return (
      <div>
        <Pagination
          currentPage={this.state.currentPage}
          totalPages={10}
          changeCurrentPage={this.changeCurrentPage}
        />
        <h2>current Page:{this.state.currentPage}</h2>
      </div>
    );
  }
}
export default App;

Props

NameTypeDefaultDescription
totalSizeNumberRequired. Total data size
sizePerPageNumber10Optional. Number of data to display in page
currentPageNumber1Required. Active page number
changeCurrentPageFunctionRequired. Page change handler. Receive current pageNumber as arg
themestringdefaultOptional. theme : default,dark, bootstrap, border-bottom, circle
showFirstLastPagesbooleantrueOptional. Show or hide first and last page.
firstPageTextstring«Optional. first page text.
lastPageTextstring»Optional. last page text.
nextPageTextstringOptional. next page text.
numberOfPagesNextToActivePageNumber1Optional. Number of page to show next to active page