Stateless Pager component (for Bootstrap).
npm install react-pager``javascript
import React from 'react';
import { render } from 'react-dom';
import Pager from 'react-pager';
class App extends React.Component {
constructor(props) {
super(props);
this.handlePageChanged = this.handlePageChanged.bind(this);
this.state = {
total: 11,
current: 7,
visiblePage: 3,
};
}
handlePageChanged(newPage) {
this.setState({ current : newPage });
}
render() {
return (
current={this.state.current}
visiblePages={this.state.visiblePage}
titles={{ first: '<|', last: '>|' }}
className="pagination-sm pull-right"
onPageChanged={this.handlePageChanged}
/>
);
}
}
window.onload = () => {
render(React.createElement(App), document.querySelector('#app'));
};
`
!First | Prev | ... | 6 | 7 | 8 | 9 | ... | Next | Last
\* Bootstrap 3.0 is required by default, but you can replace it with your own css.
Just open demo/index.html in your browser.
Or see interactive demo here.
`sh`
npm test
property. See demo.
* Improved building script.$3
* Fixed * Added a few unit-tests.See contributors.
[npm-stats]: https://nodei.co/npm/react-pager.png?compact=true
[npm-url]: https://www.npmjs.org/package/react-pager
[cc-image]: https://codeclimate.com/github/AZaviruha/pager/badges/gpa.svg
[cc-url]: https://codeclimate.com/github/AZaviruha/pager
[travis-image]: https://travis-ci.org/AZaviruha/pager.svg?branch=master
[travis-url]: https://travis-ci.org/AZaviruha/pager