Skip to content

Commit

Permalink
Merge pull request #100 from chahyunlee/feature/#95
Browse files Browse the repository at this point in the history
Feature/#95
  • Loading branch information
chahyunlee authored Feb 7, 2025
2 parents 9f41280 + 4c39308 commit 63b7c80
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/pages/ListPageCategory/ListPageCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ const ListPageCategory: React.FC = () => {
console.log('Fetched posts:', posts)
}, [posts])

useEffect(() => {
if (pageInfo.totalItemsLength > 0) {
setTotalPages(Math.ceil(pageInfo.totalItemsLength / pageInfo.size))
}
}, [selectedCategory, pageInfo.totalItemsLength, pageInfo.size])

useEffect(() => {
setActivePage(1)
Expand Down Expand Up @@ -150,6 +145,18 @@ const ListPageCategory: React.FC = () => {
}
}

useEffect(() => {
if (totalPages === 0 && pageInfo.totalItemsLength > 0) {
setTotalPages(Math.ceil(pageInfo.totalItemsLength / pageInfo.size))
}
}, [pageInfo.totalItemsLength, pageInfo.size])

useEffect(() => {
if (activePage === 1) {
setTotalPages(Math.ceil(pageInfo.totalItemsLength / pageInfo.size))
}
}, [selectedCategory, pageInfo.totalItemsLength, pageInfo.size])

return (
<div className={styles.wrapper}>
<div className={styles.header}>
Expand Down

0 comments on commit 63b7c80

Please sign in to comment.