diff --git a/src/common/KakaoShareButton.tsx b/src/common/KakaoShareButton.tsx index 5b1a375..1812e19 100644 --- a/src/common/KakaoShareButton.tsx +++ b/src/common/KakaoShareButton.tsx @@ -7,6 +7,34 @@ type KakaoShareButtonProps = { offsetBottomPx?: number; }; +// Kakao SDK 로더 +const loadKakao = (key: string) => + new Promise((resolve, reject) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const w = window as any; + if (w.Kakao) { + if (!w.Kakao.isInitialized()) w.Kakao.init(key); + resolve(); + return; + } + const s = document.createElement('script'); + s.src = 'https://t1.kakaocdn.net/kakao_js_sdk/2.7.6/kakao.min.js'; + s.integrity = + 'sha384-WAtVcQYcmTO/N+C1N+1m6Gp8qxh+3NlnP7X1U7qP6P5dQY/MsRBNTh+e1ahJrkEm'; + s.crossOrigin = 'anonymous'; + s.onload = () => { + try { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (window as any).Kakao.init(key); + resolve(); + } catch (e) { + reject(e); + } + }; + s.onerror = reject; + document.head.appendChild(s); + }); + // 328 width container 기준: 좌우 padding 18px, 상하 18px, 세로 여백 90px const KakaoShareButton = ({ onClick, @@ -26,7 +54,66 @@ const KakaoShareButton = ({ return (