diff --git a/app/components/KakaoLoginButton/KakaoLoginButton.tsx b/app/components/KakaoLoginButton/KakaoLoginButton.tsx index 82b7ca7..8bc92bd 100644 --- a/app/components/KakaoLoginButton/KakaoLoginButton.tsx +++ b/app/components/KakaoLoginButton/KakaoLoginButton.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { v4 as uuidv4 } from 'uuid'; const clientId = 'f5aa2f20e42d783654b8e8c01bfc6312'; @@ -7,14 +7,18 @@ const redirectUri = 'http://localhost:5173/oauth/kakao'; //이용자의 uuid를 받아와 state값으로 사용합니다. const getUserUUID = (): string => uuidv4(); -const userUUID = getUserUUID(); -const kakaoAuthUrl = `https://kauth.kakao.com/oauth/authorize?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=code&state=${userUUID}`; +const KakaoLoginButton: React.FC = () => { + const kakaoAuthUrl = useMemo(() => { + const userUUID = getUserUUID(); + return `https://kauth.kakao.com/oauth/authorize?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=code&state=${userUUID}`; + }, []); -const KakaoLoginButton: React.FC = () => ( - - - -); + return ( + + + + ); +}; export default KakaoLoginButton; diff --git a/package.json b/package.json index af1b9ee..c87c01d 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "@storybook/test": "8.2.5", "@types/react": "18.3.3", "@types/react-dom": "18.3.0", + "@types/uuid": "^10.0.0", "@typescript-eslint/eslint-plugin": "7.16.0", "@typescript-eslint/parser": "7.16.0", "@vanilla-extract/vite-plugin": "4.0.13", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4ac0832..e7a61d5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -78,6 +78,9 @@ importers: '@types/react-dom': specifier: 18.3.0 version: 18.3.0 + '@types/uuid': + specifier: ^10.0.0 + version: 10.0.0 '@typescript-eslint/eslint-plugin': specifier: 7.16.0 version: 7.16.0(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3) @@ -1989,6 +1992,9 @@ packages: '@types/unist@3.0.2': resolution: {integrity: sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==} + '@types/uuid@10.0.0': + resolution: {integrity: sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==} + '@types/uuid@9.0.8': resolution: {integrity: sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==} @@ -7763,6 +7769,8 @@ snapshots: '@types/unist@3.0.2': {} + '@types/uuid@10.0.0': {} + '@types/uuid@9.0.8': {} '@typescript-eslint/eslint-plugin@7.16.0(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3)':