1.2.0 • Published 3 years ago

react-pitu v1.2.0

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

React Pagination

NPM

Installation

$ yarn add react-pitu
import React, { Component } from 'react'
import Pagination from 'react-pitu';
import 'react-pitu/build/assets/styles/styles.css';

class UserComponent extends Component {
    constructor(props) {
        super(props);

        this.state = {
            perPage: 10,
            totalItemCount: 0
        };

        this.handlePaginationChange = this.handlePaginationChange.bind(this);
    }

    componentDidUpdate(prevProps) {
        if (prevProps.totalCount !== this.props.totalCount) {
            this.setState({ totalItemCount: <TOTAL_ITEM_COUNT> });
        }
    }

    handlePaginationChange(data) {
        const { cursor, itemsPerPage } = data;

        // make a next http request...
    }

    render() {
        const { perPage, totalItemCount } = this.state;

        return(
            <Pagination
                perPage={perPage}
                total={totalItemCount}
                onPropertyChange={this.handlePaginationChange}
            />
        );
    }
}

export default UserComponent;

Preview (1.1.x)

Example

Preview (1.2.x)

Example

Props

NameTypeDefaultDescription
perPageNumber5Items per page needs to show
totalNumberRequired Total items count
perPageOptionsArray5, 10, 15Per page options
navImagesObjectOptional
onPropertyChangeFunctionRequired. Pagination change handler.Will emit cursor and itemsPerPage

navImages

NameTypeDefaultDescription
rightNavImgStringpagination-right.pngPath to right arrow navigation icon
leftNavImgStringpagination-left.pngPath to left arrow navigation icon
leftMostNavImgStringpagination-left-most.pngPath to left most arrow navigation icon
rightMostNavImgStringpagination-right-most.pngPath to right most arrow navigation icon
1.2.0

3 years ago

1.1.5

4 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago