Skip to content

Comments

[fix] ClubTag 컴포넌트의 중복 key 문제 해결#379

Merged
seongwon030 merged 1 commit intodevelop-fefrom
fix/#378-club-tag-duplicate-key-FE-105
May 15, 2025
Merged

[fix] ClubTag 컴포넌트의 중복 key 문제 해결#379
seongwon030 merged 1 commit intodevelop-fefrom
fix/#378-club-tag-duplicate-key-FE-105

Conversation

@seongwon030
Copy link
Member

@seongwon030 seongwon030 commented May 7, 2025

#️⃣연관된 이슈

ex) #378

📝작업 내용

문제 상황

  • ClubTag 컴포넌트에서 중복된 key 값으로 인한 React 경고 발생
  • 빈 문자열이 태그로 들어올 때 동일한 key가 생성되는 문제

해결 방법

  1. ClubCard와 ClubProfile 컴포넌트에서 빈 태그 필터링
  2. tag.trim()을 사용하여 공백만 있는 태그도 제거
  3. 각 태그 타입별로 고유한 key 값 부여

중점적으로 리뷰받고 싶은 부분(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

논의하고 싶은 부분(선택)

빈 태그밖에 없는 카드는 나오지 않습니다. 어떻게 처리하면 좋을까요?

🫡 참고사항

Summary by CodeRabbit

  • 버그 수정
    • 동아리 태그에서 공백이나 비어 있는 태그가 표시되지 않도록 개선되었습니다.
    • 태그 표시 시 고유한 키가 적용되어 태그 렌더링의 안정성이 향상되었습니다.

- ClubCard와 ClubProfile 컴포넌트에서 빈 태그 필터링 로직 추가
- tag.trim()을 사용하여 빈 문자열 및 공백만 있는 태그 제거
- 각 태그에 고유한 key 값 부여 (division, category, tag 구분)
@seongwon030 seongwon030 requested a review from oesnuj May 7, 2025 02:02
@seongwon030 seongwon030 self-assigned this May 7, 2025
@seongwon030 seongwon030 added 💻 FE Frontend 🛠Fix 기능이 의도한 대로 동작하지 않는 버그를 수정 labels May 7, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 7, 2025

Walkthrough

ClubTag 컴포넌트 렌더링 시 key 값을 클럽 이름 또는 ID와 결합하여 고유하게 지정하도록 수정되었으며, 빈 문자열 또는 공백만 포함된 태그는 렌더링에서 제외하도록 필터링 로직이 추가되었습니다. 공개 API나 타입 선언에는 변경이 없습니다.

Changes

파일 경로 변경 요약
frontend/src/pages/ClubDetailPage/components/ClubProfile/ClubProfile.tsx
frontend/src/pages/MainPage/components/ClubCard/ClubCard.tsx
ClubTag 렌더링 시 고유한 key 지정 방식 개선, 빈/공백 태그 필터링 추가

Sequence Diagram(s)

sequenceDiagram
    participant ClubProfile
    participant ClubCard
    participant ClubTag

    ClubProfile->>ClubTag: division, category 태그 렌더링 (고유 key)
    ClubProfile->>ClubTag: tags 배열 필터링 후 렌더링 (고유 key)
    ClubCard->>ClubTag: division, category 태그 렌더링 (고유 key)
    ClubCard->>ClubTag: tags 배열 필터링 후 렌더링 (고유 key)
Loading

Assessment against linked issues

Objective Addressed Explanation
ClubTag 컴포넌트의 중복 key 문제 해결 (FE-105)

Possibly related issues

Suggested reviewers

  • oesnuj
  • uuhagyeong

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 531be86 and 5e437aa.

📒 Files selected for processing (2)
  • frontend/src/pages/ClubDetailPage/components/ClubProfile/ClubProfile.tsx (1 hunks)
  • frontend/src/pages/MainPage/components/ClubCard/ClubCard.tsx (1 hunks)
🔇 Additional comments (2)
frontend/src/pages/ClubDetailPage/components/ClubProfile/ClubProfile.tsx (1)

28-40: React 컴포넌트 키 값 개선 및 빈 태그 필터링 적용 👍

ClubTag 컴포넌트에 고유한 키 값을 부여하고 빈 태그를 필터링하는 로직이 적절하게 구현되었습니다. 클럽 이름을 활용한 키 생성 방식은 중복 키 경고 문제를 효과적으로 해결합니다.

  • divisioncategory 태그에는 클럽 이름과 조합된 고유 키가 할당됨
  • tags 배열에서는 trim() 메소드로 공백만 있는 태그를 필터링
  • 각 태그마다 tag-${name}-${tag} 형식의 고유 키 할당

이러한 변경으로 React의 중복 키 경고가 해결될 것입니다.

frontend/src/pages/MainPage/components/ClubCard/ClubCard.tsx (1)

43-51: React 컴포넌트 키 값 개선 및 빈 태그 필터링 적용 👍

ClubTag 컴포넌트에 고유한 키 값을 부여하고 빈 태그를 필터링하는 로직이 적절하게 구현되었습니다. 클럽 ID를 활용한 키 생성 방식은 중복 키 경고 문제를 효과적으로 해결합니다.

  • divisioncategory 태그에는 클럽 ID와 조합된 고유 키가 할당됨
  • tags 배열에서는 trim() 메소드로 공백만 있는 태그를 필터링
  • 각 태그마다 tag-${club.id}-${tag} 형식의 고유 키 할당

이러한 변경으로 React의 중복 키 경고가 해결될 것입니다.

참고: ClubProfile.tsx는 클럽 이름(name)을 키로 사용하는 반면, 여기서는 클럽 ID(club.id)를 사용하고 있습니다. 두 방식 모두 작동하지만, ID 사용 방식이 조금 더 안정적입니다.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link

netlify bot commented May 7, 2025

Deploy Preview for moadong ready!

Name Link
🔨 Latest commit 5e437aa
🔍 Latest deploy log https://app.netlify.com/sites/moadong/deploys/681abf36e5deb20008bcbf67
😎 Deploy Preview https://deploy-preview-379--moadong.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 41
Accessibility: 87
Best Practices: 92
SEO: 92
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@seongwon030 seongwon030 linked an issue May 7, 2025 that may be closed by this pull request
1 task
Copy link
Member

@oesnuj oesnuj left a comment

Choose a reason for hiding this comment

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

수고하셨습니다 :)

@seongwon030 seongwon030 merged commit c914817 into develop-fe May 15, 2025
5 checks passed
@seongwon030 seongwon030 deleted the fix/#378-club-tag-duplicate-key-FE-105 branch May 15, 2025 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FE Frontend 🛠Fix 기능이 의도한 대로 동작하지 않는 버그를 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] FE-105 ClubTag 컴포넌트의 중복 key 문제 해결

2 participants