Skip to content

Comments

fix: 모임 목적 하드코딩 제거 이후 로컬스토리지에서 카테고리 추출#44

Merged
kangdy25 merged 2 commits intomainfrom
hotfix/purpose-ranking
Feb 21, 2026
Merged

fix: 모임 목적 하드코딩 제거 이후 로컬스토리지에서 카테고리 추출#44
kangdy25 merged 2 commits intomainfrom
hotfix/purpose-ranking

Conversation

@kangdy25
Copy link
Collaborator

@kangdy25 kangdy25 commented Feb 21, 2026

🚀 fix: 모임 목적 하드코딩 제거 이후 로컬스토리지에서 카테고리 추출

📝 변경사항

  • 모임 목적 하드코딩 제거 이후 로컬스토리지에서 카테고리 추출

✅ 체크리스트

  • 코드 리뷰를 받았습니다
  • 테스트를 완료했습니다
  • 린터 에러가 없습니다
  • 타입 에러가 없습니다
  • 브라우저에서 테스트를 완료했습니다
  • 모바일에서 테스트를 완료했습니다 (해당되는 경우)

📸 스크린샷

UI 변경 사항이 있다면 이미지를 드래그해서 넣어주세요!

💬 리뷰어 전달사항

  • 리뷰어가 특별히 확인해야 할 사항이 있다면 적어주세요.

Summary by CodeRabbit

릴리스 노트

  • 버그 수정

    • 페이지 로딩 시 발생하는 하이드레이션 오류 해결
    • 카테고리 정보가 올바르게 유지되도록 개선
  • 개선 사항

    • 사용자가 선택한 카테고리 정보를 브라우저에 저장하여 지속적으로 유지
    • 인기 장소 표시 텍스트가 저장된 카테고리 기반으로 더 정확하게 표시
    • 공유 버튼 레이아웃 및 화면 요소 배치 소폭 개선

@vercel
Copy link

vercel bot commented Feb 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mingling-frontend Ready Ready Preview, Comment Feb 21, 2026 4:16am

@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

app/result/[id]/page.tsx에 localStorage 기반 localCategory 상태와 이를 우선 사용하는 카테고리 텍스트 결정 로직이 추가되었고, getCategoryText 시그니처가 apiCategory로 변경되었습니다. ESLint 설정에 react-hooks/set-state-in-effect 규칙을 비활성화하는 오버라이드가 추가되었습니다.

Changes

Cohort / File(s) Summary
결과 페이지 — 카테고리 상태 및 렌더링
app/result/[id]/page.tsx
localCategory 상태 추가 및 mount 시 meeting_${id}_category를 localStorage에서 로드하는 useEffect 추가. getCategoryText(category...) 시그니처가 getCategoryText(apiCategory...)로 변경되며, 3등 이후 텍스트는 localCategory 우선, 없으면 apiCategory 사용하도록 로직 수정. 일부 클래스네임/레이아웃 순서 조정 및 버튼 레이아웃 미세 조정.
ESLint 설정
eslint.config.mjs
react-hooks/set-state-in-effect 규칙을 off로 설정하는 오버라이드 추가 (기존 규칙 블록에 확장).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 설명하고 있습니다. localStorage에서 카테고리를 추출하는 주요 변경사항을 정확하게 반영합니다.
Description check ✅ Passed PR 설명이 템플릿 구조를 따르고 있으며, 체크리스트의 대부분이 완료되었습니다. 다만 변경사항이 간략하고 추가 세부사항이 부족합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix/purpose-ranking

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@kangdy25 kangdy25 merged commit 306aac2 into main Feb 21, 2026
3 checks passed
@kangdy25 kangdy25 deleted the hotfix/purpose-ranking branch February 21, 2026 04:17
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
app/result/[id]/page.tsx (2)

131-131: 의도적으로 미사용 파라미터는 _ 접두사 컨벤션 사용 권장

hot 파라미터를 사용하지 않지만 시그니처 유지를 위해 남겨두었다면, _hot으로 명명하는 것이 TypeScript/ESLint의 no-unused-vars 규칙 위반을 방지하는 관용적인 방식입니다.

♻️ 수정 제안
-    hot: boolean | undefined, // hot 파라미터를 안 쓰게 되더라도 시그니처 유지를 위해 둠
+    _hot: boolean | undefined, // 시그니처 유지용 — 의도적 미사용
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/result/`[id]/page.tsx at line 131, Rename the intentionally unused
parameter hot to _hot in the function/component signature where it's declared
(look for the parameter list containing "hot: boolean | undefined" in the page
component in app/result/[id]/page.tsx) so it follows the unused-variable
convention and avoids TypeScript/ESLint no-unused-vars warnings; update any
internal references (if any) accordingly and run lint/type checks to confirm no
further unused-var errors remain.

224-227: category 변수를 map 외부로 호이스팅 권장

meetingData는 이터레이션 간에 변하지 않으므로 category를 매 순회마다 재계산할 필요가 없습니다. map() 호출 전에 한 번만 추출하는 것이 명확하고 효율적입니다.

♻️ 수정 제안
+                    const category =
+                      meetingData?.data?.purposes?.[meetingData.data.purposes.length - 1];
                     {locationResults.map((result) => {
-                        const category =
-                          meetingData?.data?.purposes?.[meetingData.data.purposes.length - 1];
                        const categoryText = getCategoryText(category, result.hot, result.id);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/result/`[id]/page.tsx around lines 224 - 227, Hoist the computation of
category out of the locationResults.map callback since meetingData does not
change across iterations: compute const category =
meetingData?.data?.purposes?.[meetingData.data.purposes.length - 1] once before
calling locationResults.map and then pass that precomputed category into the map
where getCategoryText(category, result.hot, result.id) is invoked; update any
references inside the map to use the hoisted category to avoid repeated
recalculation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/result/`[id]/page.tsx:
- Around line 27-41: Replace the useEffect + setLocalCategory pattern by
initializing localCategory via useState's lazy initializer that reads
localStorage only on the client: remove the useEffect block that references
useEffect, setLocalCategory and id, and change the useState for localCategory to
a lazy initializer that checks typeof window !== 'undefined' and reads
localStorage.getItem(`meeting_${id}_category`) (falling back to ''), mirroring
the myNickname pattern to avoid setState-in-effect ESLint errors.

---

Nitpick comments:
In `@app/result/`[id]/page.tsx:
- Line 131: Rename the intentionally unused parameter hot to _hot in the
function/component signature where it's declared (look for the parameter list
containing "hot: boolean | undefined" in the page component in
app/result/[id]/page.tsx) so it follows the unused-variable convention and
avoids TypeScript/ESLint no-unused-vars warnings; update any internal references
(if any) accordingly and run lint/type checks to confirm no further unused-var
errors remain.
- Around line 224-227: Hoist the computation of category out of the
locationResults.map callback since meetingData does not change across
iterations: compute const category =
meetingData?.data?.purposes?.[meetingData.data.purposes.length - 1] once before
calling locationResults.map and then pass that precomputed category into the map
where getCategoryText(category, result.hot, result.id) is invoked; update any
references inside the map to use the hoisted category to avoid repeated
recalculation.

Comment on lines +27 to +41
// 로컬스토리지에서 가져온 카테고리 값을 저장할 State
const [localCategory, setLocalCategory] = useState<string>('');

const { data: midpointData, isLoading, isError } = useMidpoint(id);
const { data: meetingData } = useCheckMeeting(id);

// 컴포넌트 마운트 시 로컬스토리지 값 가져오기 (Hydration 에러 방지)
useEffect(() => {
if (typeof window !== 'undefined' && id) {
const storedCategory = localStorage.getItem(`meeting_${id}_category`);
if (storedCategory) {
setLocalCategory(storedCategory);
}
}
}, [id]);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

CI 파이프라인 실패 원인 수정 필요 — useEffect 내부의 setState 직접 호출

react-hooks/set-state-in-effect ESLint 오류로 인해 CI가 실패하고 있습니다. 같은 파일의 myNickname (Line 22–25)이 이미 useState lazy initializer + typeof window 가드 패턴으로 동일한 목적을 달성하고 있으므로, localCategory도 동일하게 리팩토링하고 useEffect를 제거하면 됩니다.

🐛 수정 제안
-  // 로컬스토리지에서 가져온 카테고리 값을 저장할 State
-  const [localCategory, setLocalCategory] = useState<string>('');
-
   ...
-
-  // 컴포넌트 마운트 시 로컬스토리지 값 가져오기 (Hydration 에러 방지)
-  useEffect(() => {
-    if (typeof window !== 'undefined' && id) {
-      const storedCategory = localStorage.getItem(`meeting_${id}_category`);
-      if (storedCategory) {
-        setLocalCategory(storedCategory);
-      }
-    }
-  }, [id]);
+  // 로컬스토리지에서 가져온 카테고리 값을 저장할 State (myNickname과 동일한 lazy initializer 패턴)
+  const [localCategory] = useState<string>(() => {
+    if (typeof window === 'undefined') return '';
+    return localStorage.getItem(`meeting_${id}_category`) || '';
+  });
🧰 Tools
🪛 ESLint

[error] 38-38: Error: Calling setState synchronously within an effect can trigger cascading renders

Effects are intended to synchronize state between React and external systems such as manually updating the DOM, state management libraries, or other platform APIs. In general, the body of an effect should do one or both of the following:

  • Update external systems with the latest state from React.
  • Subscribe for updates from some external system, calling setState in a callback function when external state changes.

Calling setState synchronously within an effect body causes cascading renders that can hurt performance, and is not recommended. (https://react.dev/learn/you-might-not-need-an-effect).

/home/jailuser/git/app/result/[id]/page.tsx:38:9
36 | const storedCategory = localStorage.getItem(meeting_${id}_category);
37 | if (storedCategory) {

38 | setLocalCategory(storedCategory);
| ^^^^^^^^^^^^^^^^ Avoid calling setState() directly within an effect
39 | }
40 | }
41 | }, [id]);

(react-hooks/set-state-in-effect)

🪛 GitHub Actions: CI

[error] 38-38: React: Calling setState synchronously within an effect. Avoid calling setState() directly within an effect (react-hooks/set-state-in-effect).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/result/`[id]/page.tsx around lines 27 - 41, Replace the useEffect +
setLocalCategory pattern by initializing localCategory via useState's lazy
initializer that reads localStorage only on the client: remove the useEffect
block that references useEffect, setLocalCategory and id, and change the
useState for localCategory to a lazy initializer that checks typeof window !==
'undefined' and reads localStorage.getItem(`meeting_${id}_category`) (falling
back to ''), mirroring the myNickname pattern to avoid setState-in-effect ESLint
errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant