Skip to content

Instantly share code, notes, and snippets.

@laserpants
Created August 20, 2015 22:05
Show Gist options
  • Save laserpants/9f3a77c1d24c0ca23cd3 to your computer and use it in GitHub Desktop.
Save laserpants/9f3a77c1d24c0ca23cd3 to your computer and use it in GitHub Desktop.
React-bootstrap paging component for Griddle
const BootstrapPager = React.createClass({
getDefaultProps() {
return {
currentPage : 0,
maxPage : 0,
maxButtons : 10
}
},
handleSelect(event, selectedEvent) {
let page = selectedEvent.eventKey
if (page > this.props.maxPage || !page)
return
this.props.setPage(page-1)
},
render() {
let maxPage = this.props.maxPage
if (maxPage < 2) {
return <span />
}
return (
<Pagination
bsSize = 'small'
items = {maxPage}
prev = {true}
next = {true}
ellipsis = {true}
maxButtons = {Math.min(this.props.maxButtons, maxPage)}
activePage = {this.props.currentPage+1}
onSelect = {this.handleSelect} />
)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment