Wondering what’s next for npm?Check out our public roadmap! »

    react-infinite-pagination
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    react-infinite-pagination

    NPM version NPM monthly download

    A React component to render a infinite pagination(without total page) just like google

    By installing this component and using my example.css you can obtain this:

    screenshot

    Installation

    yarn add react-infinite-pagination

    Usage(Hooks only)

    Example: https://codesandbox.io/s/react-infinite-pagination-example-rx32s

    import {Pagination} from 'react-infinite-pagination';
    import 'react-infinite-pagination/example.css';
    
    const Datatable = () => {
      return <Pagination current={6} />;
    };

    Props

    Name Type Description
    pageInVisible Number The number of pages to display. Default: 10
    current Number The current page selected. Default: 1
    lastPage Number The total number of pages. If undefined the pagination will infinite
    hideOnSinglePage Boolean Whether to hide pager on single page
    wrapClassName String The class name of the container of the pagination. Default: pagination
    itemClassName String The class name of the page item. Default: pagination-item
    onChange (page) => {} The callback executed when the page number is changed
    renderPageItem ({page}) => ReactNode The component to render the page item. Don't use it
    renderPrev ({page}) => ReactNode The component to render the previous button
    renderNext ({page}) => ReactNode The component to render the previous button

    FAQ

    Q: How to force update current prop?

    A: You want to update the current prop value, for example fetch data from server.

    You can use the key to re-mount the pagination component.

    const {data, pagination} = await fetch('/api/posts');
    
    <Pagination key={pagination.current} current={pagination.current} />;

    License

    MIT

    Install

    npm i react-infinite-pagination

    DownloadsWeekly Downloads

    12

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    12.6 kB

    Total Files

    8

    Last publish

    Collaborators

    • avatar