function () {
const perPage = 10
const total = 25
const lastPage = Math.ceil(total / perPage)
const [isFetching, changeIsFetching] = useState(false)
const [current, changeCurrent] = useState({
currentPage: 1,
from: Math.min(1, total),
to: Math.min(perPage, total)
})
function onPageChange(currentPage) {
changeIsFetching(true)
setTimeout(() => {
const from = Math.min((currentPage - 1 ) * perPage + 1, total)
const to = Math.min(from + perPage, total)
changeCurrent({
currentPage,
from,
to
})
changeIsFetching(false)
}, 1000)
}
const { currentPage, from, to} = current
return <Paginate
lastPage={lastPage}
total={total}
from={from}
to={to}
currentPage={currentPage}
isFetching={isFetching}
onChange={page => {
onPageChange(page)
}}
/>
}