forked from react-bootstrap-table/react-bootstrap-table2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage-button.js
53 lines (47 loc) · 1.12 KB
/
page-button.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* eslint react/require-default-props: 0 */
/* eslint jsx-a11y/href-no-hash: 0 */
import cs from 'classnames';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class PageButton extends Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(e) {
e.preventDefault();
this.props.onPageChange(this.props.page);
}
render() {
const {
page,
title,
active,
disabled,
className
} = this.props;
const classes = cs({
active,
disabled,
'page-item': true
}, className);
return (
<li className={ classes } title={ title }>
<a href="#" onClick={ this.handleClick } className="page-link">{ page }</a>
</li>
);
}
}
PageButton.propTypes = {
onPageChange: PropTypes.func.isRequired,
page: PropTypes.oneOfType([
PropTypes.node,
PropTypes.number,
PropTypes.string
]).isRequired,
active: PropTypes.bool.isRequired,
disabled: PropTypes.bool.isRequired,
className: PropTypes.string,
title: PropTypes.string
};
export default PageButton;