fix: 페이징 단위 넘기기 버튼 오류 수정

- 다음 단위 없는데도 넘어가는 현상 수정
This commit is contained in:
yoosangwook 2024-10-24 17:57:38 +09:00
parent b5eefeca7e
commit 4eb2497139
3 changed files with 11 additions and 2 deletions

View File

@ -138,7 +138,7 @@ export default function Playground() {
pageNo: 1,
pageSize: 10,
pagePerBlock: 10,
totalCount: 501,
totalCount: 26,
handleChangePage: (page) => {
console.log('page', page)
},

View File

@ -31,7 +31,7 @@ export default function QPagination(props) {
<button
onClick={() => {
if (currentPage === totalPages) return
handlePage(Math.max(1, pageGroup * pagePerBlock + 1))
if (pageGroup * pagePerBlock + 1 <= totalPages) handlePage(Math.max(1, pageGroup * pagePerBlock + 1))
}}
></button>
</li>

View File

@ -28,6 +28,15 @@ const usePagination = ({ pageNo = 1, pageSize = 10, pagePerBlock = 10, totalCoun
return i + startPage
})
// console.log('pageRange', pageRange)
// console.log('startPage', startPage)
// console.log('endPage', endPage)
// console.log('totalPages', totalPages)
// console.log('pageGroup', pageGroup)
// console.log('pagePerBlock', pagePerBlock)
// console.log('currentPage', currentPage)
// console.log('pageNo', pageNo)
return { currentPage, changePage, pageGroup, totalPages, pages, startPage, endPage, pageRange }
}