feat: 페이지네이션 추가#50
Conversation
📝 WalkthroughWalkthrough클라이언트 측 페이지네이션을 도입합니다. TIL 페이지에 currentPage 상태, itemsPerPage 및 currentData 슬라이싱을 추가하고, 새로운 Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant TilsPage as TIL 페이지
participant Pagination as Pagination 컴포넌트
participant TilList as TilList 컴포넌트
User->>Pagination: 페이지 버튼 클릭
Pagination->>TilsPage: onPageChange(pageNumber)
TilsPage->>TilsPage: currentPage 상태 업데이트
TilsPage->>TilsPage: currentData 재계산 (sortedItems 슬라이싱)
TilsPage->>TilList: currentData 전달
TilList->>User: 페이지된 항목 렌더링
TilsPage->>Pagination: currentPage, totalPages props 업데이트
Pagination->>User: 버튼 상태 갱신
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@app/`(with-sidebar)/tils/page.tsx:
- Around line 71-80: When totalPages (computed from sortedItems and
itemsPerPage) decreases currentPage can become out-of-range causing currentData
to be empty; add a guard to clamp currentPage whenever
sortedItems/itemsPerPage/totalPages change by using setCurrentPage(Math.max(1,
Math.min(currentPage, totalPages))). Implement this in a useEffect that watches
sortedItems or totalPages and adjusts currentPage via setCurrentPage so
pagination recovers automatically (affects totalPages, currentPage,
setCurrentPage, currentData, handlePageChange).
🧹 Nitpick comments (1)
components/common/Pagination.tsx (1)
39-95: totalPages가 1 이하일 때 컨트롤 노출을 막아 UX 혼란을 줄여주세요.현재는 totalPages=0/1에서도 이전/다음 버튼이 노출되어 의미 없는 UI가 생깁니다. 컨트롤 자체를 숨기면 더 명확합니다.
♻️ 제안 변경
+ if (totalPages <= 1) return null; + return ( <div className="mt-7.5 flex items-center justify-center gap-1.5">
1) 작업한 이슈번호
#37
2) 변경 요약 (What & Why)
3) 스크린샷/동영상 (UI 변경 시)
4) 상세 변경사항
5) 참고사항
Summary by CodeRabbit
릴리스 노트
✏️ Tip: You can customize this high-level summary in your review settings.