-
Notifications
You must be signed in to change notification settings - Fork 2
[#16] 리뷰 평점(별점) 컴포넌트 구현 #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
huuitae
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 코멘트 확인 부탁드립니다!
| {[...Array(maxRating)].map((_, i) => { | ||
| const score = maxRating - i; | ||
| const count = distribution[score] ?? 0; | ||
| return ( | ||
| <ScoreBar | ||
| key={score} | ||
| score={score} | ||
| reviewCount={count} | ||
| totalCount={totalReviews} | ||
| /> | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 Array.from({length: 5})나 new Array(maxRating).fill(0)로 배열을 만들어 사용하는 것이 나을 것 같습니다!
Array(maxRating)으로 배열을 만들면 아무것도 들어있지 않은 빈 배열을 사용하기 때문에 map() 함수가 의도대로 동작하지 않을 수 있다고 합니다.
실제로 배열을 만들면 [ <5 empty items> ]이 출력되고, index를 사용하려해도 undefined가 출력됩니다.
따라서 스프레드 연산자를 통해 사용하신 것 같은데, 이러면 배열을 두 번 만드는셈이 되니 한 번에 생성해서 사용하는게 나아보입니다!
📄 PR 내용 요약
공통으로 사용되는 리뷰 평점(별점) 컴포넌트 구현
✅ 작업 내용 상세
별점을 표시하는 컴포넌트로 다양한 크기와 옵션을 지원합니다.
스토리북 문서 참고해주세요!
📸 스크린샷 (선택사항)
기본
세부 평점(반응형)
💬 참고 사항
테일윈드 컨피그 파일에 아이콘 사이즈 이름 수정하면서 아이콘 컴포넌트도 같이 수정되었습니다. 참고 부탁드립니다!
"2md": "ic-2md", ->md2: "ic-md2"