refactor: Refactor usePagination hook to include useEffect
This commit is contained in:
parent
63b500e0c0
commit
429832b8b7
@ -1,4 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
/**
|
||||
* 페이지네이션 훅
|
||||
@ -14,6 +14,10 @@ const usePagination = ({ pageNo = 1, pageSize = 10, pagePerBlock = 10, totalCoun
|
||||
setCurrentPage(page)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentPage(pageNo)
|
||||
}, [pageNo])
|
||||
|
||||
const pageGroup = Math.floor((currentPage - 1) / pagePerBlock) + 1
|
||||
const totalPages = Math.ceil(totalCount / pageSize)
|
||||
const pages = Array.from({ length: totalPages }, (_, i) => i + 1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user