Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | import React from 'react'
import { Pagination, PaginationItem, PaginationLink } from 'reactstrap'
interface Props {
current: number
count: number
onClick: Function
}
export default class PaginationWrapper extends React.Component<Props> {
onClick(i: number) {
const { onClick } = this.props
return (e: React.MouseEvent<HTMLElement>) => {
e.preventDefault()
if (onClick) {
onClick(i)
}
}
}
render() {
const { current, count } = this.props
if (current < 1 || count < 1) {
return null
}
const range = [...Array(count).keys()]
const items = range.map((v, k) => {
const page = k + 1
return (
<PaginationItem key={page} active={page === current}>
<PaginationLink onClick={this.onClick(page)}>{page}</PaginationLink>
</PaginationItem>
)
})
return (
<Pagination>
<PaginationItem disabled={current === 1}>
<PaginationLink previous onClick={this.onClick(1)} />
</PaginationItem>
{items}
<PaginationItem disabled={current === count}>
<PaginationLink next onClick={this.onClick(count)} />
</PaginationItem>
</Pagination>
)
}
}
|