Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions src/components/members/main/TeamLeaderCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,31 @@ const TeamLeaderCard = ({
function useDetectWebView() {
const userAgent = navigator.userAgent;

// iOS 웹뷰 감지
const isIOS = /iPhone|iPad|iPod/.test(userAgent);
const isWebKit = /AppleWebKit/.test(userAgent);
const isSafari = /Safari/.test(userAgent) || /Version\/[\d.]+.*Safari/.test(userAgent); // Safari 또는 Version/{version}.Safari 패턴을 포함하지 않는 경우
const isNotCriOS = !/CriOS/.test(userAgent);
const isNotFxiOS = !/FxiOS/.test(userAgent);
// SOPT-iOS 웹뷰 감지
const isIOSWebView = /SOPT-iOS/.test(navigator.userAgent);

const isIOSWebView = isIOS && isWebKit && isNotCriOS && isNotFxiOS && !isSafari;

// Android 웹뷰 감지
const isAndroid = /Android/.test(userAgent);
const isAndroidWebView = isAndroid && /wv/.test(userAgent);
// SOPT-Android 웹뷰 감지 방법:
// 2. User-Agent에 "wv"가 있으면 웹뷰 (기존 방법)
// 3. User-Agent가 정확히 "Chrome/56.0.0.0 Mobile"이면 앱에서 설정한 값이므로 웹뷰
const hasWvInUserAgent = /wv/.test(userAgent);
const isChrome56Mobile = /Chrome\/56\.0\.0\.0 Mobile/.test(userAgent);
const isAndroidWebView = hasWvInUserAgent || isChrome56Mobile;

return {
isWebView: isIOSWebView || isAndroidWebView,
isIOSWebView,
isAndroidWebView,
isIOS,
isAndroid,
};
}
Comment on lines 60 to 78

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

함수 이름을 detectWebView로 변경하세요.

use로 시작하는 함수명은 React Hook 규칙을 따라야 하지만, 이 함수는 Hook을 사용하지 않고 중첩 함수 내부(line 83)에서 호출되므로 Rules of Hooks를 위반합니다. 정적 분석 도구가 정확하게 이를 감지했습니다.

다음 diff를 적용하여 함수명을 수정하세요:

-  function useDetectWebView() {
+  function detectWebView() {
     const userAgent = navigator.userAgent;
 
     // SOPT-iOS 웹뷰 감지

그리고 line 83에서 호출 부분도 수정하세요:

-    const webViewInfo = useDetectWebView();
+    const webViewInfo = detectWebView();

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/components/members/main/TeamLeaderCard/index.tsx around lines 60 to 78,
the function useDetectWebView should be renamed to detectWebView because it does
not use React hooks and its current name starting with "use" violates Rules of
Hooks; rename the function to detectWebView and update its call site at line 83
accordingly (change useDetectWebView() to detectWebView()), keeping the
implementation and returned object identical so behavior remains the same.


const openNotionUrl = (url: string) => {
const notionDeepLinkUrl = url.replace('https://', 'notion://');
const originalUrl = url;
const webViewInfo = useDetectWebView();

alert('android: ' + useDetectWebView().isAndroidWebView + ' ' + 'ios: ' + useDetectWebView().isIOSWebView);
// 웹뷰 환경이면 원래 URL 사용
if (useDetectWebView().isWebView) {
window.open(originalUrl, '_blank');
//TODO: 웹뷰 환경일 때 Deep Link 처리 앱팀 쪽 협력 요청필요
if (webViewInfo.isWebView) {
window.location.href = originalUrl;
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/pages/members/team-leaders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const TeamLeadersPage = () => {
university='Test University'
activities={[]}
introduction='Test Introduction'
selfIntroduction='https://www.notion.so/sopt-official/27c1e48dd96080939147f2aa54a1b795?source=copy_link'
competitionData='https://www.notion.so/sopt-official/Snappin-2c51e48dd96081139201c3615f4f449f?source=copy_link'
selfIntroduction='https://www.notion.so/sopt-makers/SOPT-makers-11cec9382470407099eb313ff09963f6?source=copy_link'
competitionData='https://www.notion.so/sopt-makers/SOPT-Playground-1a976042aac280a08351da869df3ff82?source=copy_link'
/>
)}
<TeamLeaderCardsWrapper>
Expand Down
Loading