react-pager
Version:
Stateless Pager component (for Bootstrap).
113 lines (79 loc) • 2.49 kB
Markdown
[![Code Climate][cc-image]][cc-url]
[![Build Status][travis-image]][travis-url]<br />
[![NPM version][npm-stats]][npm-url]
```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 (
<Pager
total={this.state.total}
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'));
};
```

\* 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](http://azaviruha.github.io/demo/react-pager/).
```sh
npm test
```
* @kallaspriit fixed [
* Updates devDependencies
* Move building procedure to Docker
* Fixed [
* Rewrited all to ES6.
* Switched from gulp + browserify to webpack.
* Now officially supports only React >= 15.0.0
* Updated to React 15. Thanks to contributors!
* Updated to React 0.13.
* Updated local demo.
* Added `titles` property. See [demo](http://jsfiddle.net/azaviruha/kb3gN/10213/).
* Improved building script.
* Fixed `<li class="undefined" ..` in "more" and "less" buttons.
* Added a few unit-tests.
See [contributors](https://github.com/AZaviruha/pager/graphs/contributors).
[]: https://nodei.co/npm/react-pager.png?compact=true
[]: https://www.npmjs.org/package/react-pager
[]: https://codeclimate.com/github/AZaviruha/pager/badges/gpa.svg
[]: https://codeclimate.com/github/AZaviruha/pager
[]: https://travis-ci.org/AZaviruha/pager.svg?branch=master
[]: https://travis-ci.org/AZaviruha/pager