0.0.0 • Published 8 years ago

reaginate v0.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

React Pager

A ReactJS component to render a pagination.

Installation

npm install reaginate --save

Screenshot

Image of reaginate component

Props

NameTypeDescription
currentPageNumberRequired. The current page to display.
totalPagesNumberRequired. The total number of pages.
onPageChangeNumberRequired. A callback with the page number as an argument for when the page changes.
onRefreshFunctionA function when the refresh button is clicked. If omitted, the button is not displayed.
displayLabelStringA label to display feedback for the user. i.e. Displaying 1 to 50 of 200 messages

API

<Reaginate
    currentPage={ pager.currentPage }
    totalPages={ pager.totalPages }
    onPageChange={ this.onPageChange }
    onRefresh={ this.onRefresh }
    displayLabel={ `Displaying events 101 - 150 of 7765` }/>

Example usage

import React, {Component} from 'react';

import 'reaginate/src/reaginate.scss'
import Reaginate from 'reaginate';

class MessageInbox extends Component {

    constructor(props) {
        super(props);
        // Fetch data and then set state...
        this.state = {
            pager: {
                currentPage: 1,
                totalPages: 20
            }
        };
    }

    onPageChange(page) {
        const {totalPages} = this.state.pager;
        this.setState({
            pager: {
                currentPage: page,
                totalPages: totalPages
            }
        });
    }


    render() {
        const {pager} = this.state;
        return (
          <div>
              <Grid />
              <Reaginate
                  currentPage={ pager.currentPage }
                  totalPages={ pager.totalPages }
                  onPageChange={ this.onPageChange }
                  displayLabel={ `Displaying events 101 - 150 of 7765` }/>
          </div>
        );
    }
}