Skip to content

[fix] 프로모션 WebView에서 동아리 상세 페이지 이동 불가 문제 수정#16

Open
seongwon030 wants to merge 2 commits into
mainfrom
fix/webview-navigate-webview-handler
Open

[fix] 프로모션 WebView에서 동아리 상세 페이지 이동 불가 문제 수정#16
seongwon030 wants to merge 2 commits into
mainfrom
fix/webview-navigate-webview-handler

Conversation

@seongwon030
Copy link
Copy Markdown
Member

@seongwon030 seongwon030 commented May 6, 2026

문제

프로모션 WebView(이벤트 정보 페이지)에서 "동아리 정보 보러가기" 버튼을 클릭해도 동아리 상세 페이지로 이동하지 않는 버그

원인

웹에서 NAVIGATE_WEBVIEW 메시지를 전송하지만, webview/[slug].tsx가 사용하는 useWebViewMessageHandler 훅에 해당 타입이
정의되어 있지 않아 default 케이스(console.warn)로 빠지며 동작하지 않았음.

home-webview-screen.tsx는 자체 handleMessage에서 NAVIGATE_WEBVIEW를 직접 처리해 정상 동작했으나, 공유 훅에는 누락된 상태였음

수정 내용

  • types/webview-message.types.ts — NAVIGATE_WEBVIEW 타입 및 페이로드(slug: string) 추가
  • hooks/use-webview-message-handler.ts — onNavigateWebview 콜백 옵션 추가 및 switch 케이스 처리
  • app/webview/[slug].tsx — handleNavigateWebview 구현 및 훅에 전달
    • club/{id} → /club/[id] 네이티브 스크린으로 이동
    • 그 외 slug → 해당 WebView 스크린으로 이동

Summary by CodeRabbit

새로운 기능

  • 웹뷰 네비게이션 기능이 추가되었습니다. 애플리케이션 내에서 특정 페이지로 직접 이동할 수 있습니다.
  • 클럽 페이지와 기타 웹뷰 페이지로의 동적 라우팅이 지원됩니다.

NAVIGATE_WEBVIEW 메시지 타입을 WebViewMessageTypes에 추가하고
useWebViewMessageHandler 훅에 onNavigateWebview 콜백을 지원하여
webview/[slug].tsx에서도 동아리 상세 화면으로 이동할 수 있도록 수정
@seongwon030 seongwon030 requested a review from SeongHoonC May 6, 2026 01:17
@seongwon030 seongwon030 self-assigned this May 6, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

워크스루

웹뷰 내비게이션 메시지 처리를 위한 새로운 NAVIGATE_WEBVIEW 메시지 타입을 추가하고, 웹뷰 메시지 핸들러 훅에서 이를 처리하며, 웹뷰 페이지 컴포넌트에서 라우팅 로직을 구현하였습니다.

변경 사항

WebView 내비게이션 메시지 기능

레이어 / 파일(들) 요약
메시지 타입 정의
types/webview-message.types.ts
NAVIGATE_WEBVIEW 메시지 타입을 WebViewMessageTypes에 추가하고, WebViewMessage 판별식 유니온에 { type: 'NAVIGATE_WEBVIEW'; payload: { slug: string } } 바리언트를 확장합니다.
훅 로직 확장
hooks/use-webview-message-handler.ts
UseWebViewMessageHandlerOptions 인터페이스에 onNavigateWebview?: (slug: string) => void 콜백을 추가하고, 메시지 스위치에 NAVIGATE_WEBVIEW 케이스를 구현하여 콜백을 호출합니다. 의존성 배열에 추가합니다.
페이지 라우팅 구현
app/webview/[slug].tsx
handleNavigateWebview(slug: string) 함수를 추가하여 'club/' 접두사 슬러그는 /club/[id]로, 나머지는 /webview/[slug]로 라우팅하고, 훅에 onNavigateWebview 핸들러로 연결합니다.

예상 코드 리뷰 노력

🎯 3 (중간) | ⏱️ ~20분

관련 가능 PR

  • Moadong/moadong-react-native#5: WebView 메시징 시스템을 수정하여 동일한 훅 및 타입 파일에서 새로운 메시지 바리언트 및 콜백 연결을 추가합니다.
  • Moadong/moadong-react-native#10: useWebViewMessageHandlerWebViewMessage 타입을 확장하여 새로운 콜백 옵션 및 스위치 케이스를 추가합니다.
  • Moadong/moadong-react-native#15: NAVIGATE_WEBVIEW를 통한 WebView 내비게이션 처리와 club 슬러그 라우팅을 구현하여 직접적으로 관련됩니다.

제안된 리뷰어

  • SeongHoonC
  • oesnuj
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 제목은 WebView에서 동아리 상세 페이지 이동 불가 문제를 수정한다는 주요 변경사항을 명확하게 요약하고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/webview-navigate-webview-handler

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

Copy link
Copy Markdown

@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/webview/[slug].tsx (2)

90-97: ⚡ Quick win

handleNavigateWebviewuseCallback으로 감싸는 것을 권장합니다.

handleBack과 마찬가지로 handleNavigateWebview도 렌더링마다 새 함수 참조가 생성되어 useWebViewMessageHandler 내부의 handleMessage 콜백도 매 렌더마다 재생성됩니다. useCallback으로 감싸면 불필요한 재생성을 방지할 수 있습니다.

♻️ 제안 수정
-  const handleNavigateWebview = (slug: string) => {
+  const handleNavigateWebview = useCallback((targetSlug: string) => {
-    if (slug.startsWith('club/')) {
+    if (targetSlug.startsWith('club/')) {
-      const clubId = slug.replace('club/', '');
+      const clubId = targetSlug.slice('club/'.length);
       router.push({ pathname: '/club/[id]', params: { id: clubId } });
     } else {
-      router.push({ pathname: '/webview/[slug]', params: { slug } });
+      router.push({ pathname: '/webview/[slug]', params: { slug: targetSlug } });
     }
-  };
+  }, [router]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/webview/`[slug].tsx around lines 90 - 97, The handleNavigateWebview
function is recreated on every render causing useWebViewMessageHandler's
internal handleMessage callback to be regenerated; wrap handleNavigateWebview in
React.useCallback (similar to handleBack) so it memoizes across renders,
referencing router.push and keeping the same logic for the 'club/' branch
(clubId extraction and router.push to '/club/[id]') and the else branch
(router.push to '/webview/[slug]'); ensure its dependency array includes only
values used (e.g., router) to avoid stale closures.

90-90: 💤 Low value

파라미터 이름 slug가 외부 스코프의 slug를 섀도잉합니다.

Line 50의 useLocalSearchParams에서 선언된 slughandleNavigateWebview의 파라미터 이름이 동일하여 혼동의 여지가 있습니다. targetSlug 또는 navigationSlug 등으로 구분하면 가독성이 향상됩니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/webview/`[slug].tsx at line 90, The parameter name slug in
handleNavigateWebview shadows the outer slug from useLocalSearchParams; rename
the parameter (e.g., targetSlug or navigationSlug) and update all references
inside handleNavigateWebview and any call sites to use the new name so it no
longer conflicts with the outer slug variable declared by useLocalSearchParams,
preserving the same behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/webview/`[slug].tsx:
- Around line 91-92: The current extraction of clubId using
slug.replace('club/', '') is fragile; update the clubId computation to derive
the substring after the prefix using the known prefix length (e.g., when
slug.startsWith('club/')) by using slug.slice('club/'.length) (or
slug.substring) and then validate that clubId is non-empty before routing;
locate the slug.startsWith('club/') check and the clubId variable in
app/webview/[slug].tsx and replace the replace-based extraction with a
slice-based extraction plus an empty-ID guard to avoid navigating to /club/ for
an empty id.

---

Nitpick comments:
In `@app/webview/`[slug].tsx:
- Around line 90-97: The handleNavigateWebview function is recreated on every
render causing useWebViewMessageHandler's internal handleMessage callback to be
regenerated; wrap handleNavigateWebview in React.useCallback (similar to
handleBack) so it memoizes across renders, referencing router.push and keeping
the same logic for the 'club/' branch (clubId extraction and router.push to
'/club/[id]') and the else branch (router.push to '/webview/[slug]'); ensure its
dependency array includes only values used (e.g., router) to avoid stale
closures.
- Line 90: The parameter name slug in handleNavigateWebview shadows the outer
slug from useLocalSearchParams; rename the parameter (e.g., targetSlug or
navigationSlug) and update all references inside handleNavigateWebview and any
call sites to use the new name so it no longer conflicts with the outer slug
variable declared by useLocalSearchParams, preserving the same behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e9e9ee7f-6820-42ae-820c-a10ed4d6877f

📥 Commits

Reviewing files that changed from the base of the PR and between 263febf and cd87d43.

📒 Files selected for processing (3)
  • app/webview/[slug].tsx
  • hooks/use-webview-message-handler.ts
  • types/webview-message.types.ts

Comment thread app/webview/[slug].tsx Outdated
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