Skip to content

Conversation

@kyungkiK
Copy link

@kyungkiK kyungkiK commented Jan 7, 2025

요구사항

기본

  • 스프린트 미션 5 ~ 7에 대해 typescript를 적용해주세요

심화

  • any타입을 최소한으로 써주세요

주요 변경사항

  • jsx -> tsx 리팩토링

멘토에게

  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

@kyungkiK kyungkiK requested a review from devToram January 7, 2025 08:12
@kyungkiK kyungkiK self-assigned this Jan 7, 2025
@kyungkiK kyungkiK added the 순한맛🐑 마음이 많이 여립니다.. label Jan 7, 2025
Copy link
Collaborator

@devToram devToram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드 전반적으로 너무 잘짜셨네요 💯 👍

Comment on lines +24 to +30
function getPageSize(width: number): number {
if (width <= 767) {
return 4; // 화면 너비가 768px 미만이면 한 페이지에 4개
} else if (width <= 1199) {
return 6; // 화면 너비가 768px 이상이면 한 페이지에 6개
} else {
return 10; // 화면 너비가 1200px 이상이면 한 페이지에 10개
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요기 사용하는 수들을 묶어서 object 로 만들어도 좋을 거 같아요!

getPageSize(window.innerWidth)
); // 페이지 크기 상태
const [currentPage, setCurrentPage] = useState<number>(1); // 현재 페이지 상태
const [orderBy, setOrderBy] = useState<string>("recent"); // 정렬 기준 (최신순)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기는 그냥 string 이 아닌 "recent" 등과 같이 정해진 string 만 올 수 있기 때문에 그 string 들을 묶은 타입을 만드는 걸 추천드려요!
type SortCategory = "recent" as const | "name" as const

onPageChange,
}: PaginationProps) {
const totalPages = Math.ceil(totalItems / itemsPerPage); // 전체 페이지 수 계산
const pageRange = 5; // 한 번에 보여줄 페이지 버튼 개수
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거는 상수라 밖으로 빼줘도 될 거 같아요!

@devToram devToram merged commit 8cadaaf into codeit-bootcamp-frontend:React-김경기 Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

순한맛🐑 마음이 많이 여립니다..

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants