diff --git a/src/pages/Share/Share.jsx b/src/pages/Share/Share.jsx index 3f9ab766..0f943550 100644 --- a/src/pages/Share/Share.jsx +++ b/src/pages/Share/Share.jsx @@ -22,6 +22,7 @@ const SharePage = () => { try { const res = await getStarContent(starid); setStarP(res); + console.log(res); } catch (error) { console.error("Error fetching star data:", error); } @@ -35,14 +36,13 @@ const SharePage = () => { const handleCapture = async () => { setIsButtonVisible(false); - try { + + setTimeout(async () => { const canvas = await html2canvas(captureRef.current, { useCORS: true }); await captureScreenshot(canvas); - } catch (error) { - console.error("Error capturing screenshot:", error); - } finally { setIsButtonVisible(true); - } + console.log("버튼 true설정 완료"); + }, 100); }; const starData = starP && starP.data ? starP.data : null; diff --git a/src/utils/share.js b/src/utils/share.js index a39f783b..d41960e5 100644 --- a/src/utils/share.js +++ b/src/utils/share.js @@ -8,14 +8,18 @@ export const captureScreenshot = async (canvas) => { // Web Share API 사용 if (navigator.share) { + alert("클릭"); navigator .share({ files: [new File([blob], "start.png", { type: "image/png" })], title: "STAR.T", text: "likelion-start.site", }) - .then(() => console.log("Share was successful.")) - .catch((error) => console.log("Sharing failed", error)); + .then(() => alert("성공")) + .catch((error) => { + console.log("Sharing failed", error); + alert(error); + }); } else { alert("모바일 기기에서 실행해주세요!"); }