react-js-pagination vs react-paginate
React Pagination Libraries
react-js-paginationreact-paginate

React Pagination Libraries

React pagination libraries are tools that help developers implement pagination in React applications. Pagination is the process of dividing a large set of data into smaller, manageable chunks or pages, making it easier for users to navigate through the data. These libraries provide pre-built components and functionalities to handle pagination, such as displaying page numbers, next/previous buttons, and handling user interactions to fetch or display data for the selected page. They often come with customizable styles, accessibility features, and support for various pagination strategies, such as infinite scrolling or traditional page-based navigation. By using a pagination library, developers can save time and effort in building pagination from scratch and ensure a more consistent and user-friendly experience in their applications.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
react-js-pagination0350-506 years agoCC0-1.0
react-paginate02,770115 kB68a year agoMIT

Feature Comparison: react-js-pagination vs react-paginate

Customization

  • react-js-pagination:

    react-js-pagination offers basic customization options, such as changing the number of items per page, the total number of items, and the styles of the pagination buttons. However, it is relatively limited compared to react-paginate in terms of layout and design flexibility.

  • react-paginate:

    react-paginate provides extensive customization capabilities, allowing developers to fully control the pagination UI. It supports custom class names, styles, and even the ability to render custom components for each pagination item, making it much more versatile for design-oriented projects.

Accessibility

  • react-js-pagination:

    react-js-pagination is designed with accessibility in mind, providing ARIA attributes and keyboard navigation support out of the box. It ensures that the pagination controls are usable by people with disabilities, which is a crucial aspect of modern web development.

  • react-paginate:

    react-paginate also emphasizes accessibility, but it requires developers to implement some aspects manually, such as adding ARIA attributes and ensuring keyboard navigation. While it is flexible, it may require more effort to make it fully accessible compared to react-js-pagination.

Performance

  • react-js-pagination:

    react-js-pagination is lightweight and performs well for small to medium-sized datasets. Its simple implementation means that it does not introduce significant overhead, making it a good choice for applications where performance is a concern.

  • react-paginate:

    react-paginate is also performant, but its flexibility and customization features can lead to more complex implementations. For very large datasets, developers need to ensure that they implement pagination efficiently to avoid performance bottlenecks.

Ease of Integration

  • react-js-pagination:

    react-js-pagination is very easy to integrate into existing React projects. Its API is straightforward, and it requires minimal setup to get started. This makes it a great choice for developers who need a quick and simple solution for pagination.

  • react-paginate:

    react-paginate requires a bit more setup due to its customizable nature, but it is still relatively easy to integrate. Developers need to handle the pagination logic (e.g., calculating the current page, total pages) and pass it to the component, which may require more initial effort.

Code Example

  • react-js-pagination:

    Simple Pagination with react-js-pagination

    import React, { useState } from 'react';
    import Pagination from 'react-js-pagination';
    
    const MyComponent = () => {
      const [activePage, setActivePage] = useState(1);
      const handlePageChange = (pageNumber) => {
        setActivePage(pageNumber);
      };
    
      return (
        <div>
          <Pagination
            activePage={activePage}
            itemsCountPerPage={10}
            totalItemsCount={450}
            pageRangeDisplayed={5}
            onChange={handlePageChange}
          />
        </div>
      );
    };
    
    export default MyComponent;
    
  • react-paginate:

    Custom Pagination with react-paginate

    import React from 'react';
    import ReactPaginate from 'react-paginate';
    
    const MyComponent = () => {
      const handlePageClick = (data) => {
        console.log(data.selected);
      };
    
      return (
        <div>
          <ReactPaginate
            previousLabel={'previous'}
            nextLabel={'next'}
            breakLabel={'...' }
            pageCount={10}
            marginPagesDisplayed={2}
            pageRangeDisplayed={5}
            onPageChange={handlePageClick}
            containerClassName={'pagination'}
            pageClassName={'page-item'}
            pageLinkClassName={'page-link'}
            previousClassName={'previous'}
            nextClassName={'next'}
            breakClassName={'break'}
            activeClassName={'active'}
          />
        </div>
      );
    };
    
    export default MyComponent;
    

How to Choose: react-js-pagination vs react-paginate

  • react-js-pagination:

    Choose react-js-pagination if you need a simple, lightweight pagination component that is easy to integrate and customize. It is ideal for projects that require basic pagination functionality without a lot of overhead.

  • react-paginate:

    Choose react-paginate if you need a more flexible and customizable pagination solution that supports various layouts and styles. It is suitable for projects that require more control over the pagination UI and behavior, and it works well with larger datasets.

README for react-js-pagination

Build Status

NPM

react-js-pagination

A ReactJS dumb component to render a pagination.

The component comes with no built-in styles. HTML layout compatible with Bootstrap 3 pagination stylesheets.

If you would like it to work for Bootstrap 4, you will need to add 2 additional props when using this component:

itemClass="page-item"
linkClass="page-link"

Installation

Install react-js-pagination with npm:

$ npm install react-js-pagination

Usage

Very easy to use. Just provide props with total amount of things that you want to display on the page.

import React, { Component } from "react";
import ReactDOM from "react-dom";
import Pagination from "react-js-pagination";
require("bootstrap/less/bootstrap.less");

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      activePage: 15
    };
  }

  handlePageChange(pageNumber) {
    console.log(`active page is ${pageNumber}`);
    this.setState({activePage: pageNumber});
  }

  render() {
    return (
      <div>
        <Pagination
          activePage={this.state.activePage}
          itemsCountPerPage={10}
          totalItemsCount={450}
          pageRangeDisplayed={5}
          onChange={this.handlePageChange.bind(this)}
        />
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById("root"));

Check Live example

Example

Params

NameTypeDefaultDescription
totalItemsCountNumberRequired. Total count of items which you are going to display
onChangeFunctionRequired. Page change handler. Receive pageNumber as arg
activePageNumber1Required. Active page
itemsCountPerPageNumber10Count of items per page
pageRangeDisplayedNumber5Range of pages in paginator, exclude navigation blocks (prev, next, first, last pages)
prevPageTextString / ReactElementText of prev page navigation button
firstPageTextString / ReactElement«Text of first page navigation button
lastPageTextString / ReactElement»Text of last page navigation button
nextPageTextString / ReactElementText of next page navigation button
getPageUrlFunctionGenerate href attribute for page
innerClassStringpaginationClass name of <ul> tag
activeClassStringactiveClass name of active <li> tag
activeLinkClassStringClass name of active <a> tag
itemClassStringDefault class of the <li> tag
itemClassFirstStringClass of the first <li> tag
itemClassPrevStringClass of the previous <li> tag
itemClassNextStringClass of the next <li> tag
itemClassLastStringClass of the last <li> tag
disabledClassStringdisabledClass name of the first, previous, next and last <li> tags when disabled
hideDisabledBooleanfalseHide navigation buttons (prev, next, first, last) if they are disabled.
hideNavigationBooleanfalseHide navigation buttons (prev page, next page)
hideFirstLastPagesBooleanfalseHide first/last navigation buttons
linkClassStringDefault class of the <a> tag
linkClassFirstStringClass of the first <a> tag
linkClassPrevStringClass of the previous <a> tag
linkClassNextStringClass of the next <a> tag
linkClassLastStringClass of the last <a> tag