From 3f51ec1bf3fbc67c30330f6fe6d07d2bfb0eda56 Mon Sep 17 00:00:00 2001 From: seoAreum <1971236@hansung.ac.kr> Date: Sat, 20 Jan 2024 05:41:22 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EB=A0=88=ED=81=90=EB=B6=81=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=ED=9B=84=20=EB=85=B8=ED=8A=B8=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=8B=9C=20=EC=97=90=EB=9F=AC=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=9D=B4=EC=8A=88=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/LecueNote/components/ShowColorChart/index.tsx | 12 +++--------- src/LecueNote/hooks/useGetPresignedUrl.ts | 9 ++++++++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/LecueNote/components/ShowColorChart/index.tsx b/src/LecueNote/components/ShowColorChart/index.tsx index 1f009a2d..507db0e8 100644 --- a/src/LecueNote/components/ShowColorChart/index.tsx +++ b/src/LecueNote/components/ShowColorChart/index.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef } from 'react'; +import { useRef } from 'react'; import { IcCameraSmall } from '../../../assets'; import { BG_COLOR_CHART } from '../../constants/colorChart'; @@ -19,7 +19,8 @@ function ShowColorChart({ handleIconFn, }: ShowColorChartProps) { const imgRef = useRef(null); - const { data } = useGetPresignedUrl(); + // 여기 + useGetPresignedUrl(setPresignedUrl, setFileName); const handleImageUpload = () => { const fileInput = imgRef.current; @@ -44,13 +45,6 @@ function ShowColorChart({ } }; - useEffect(() => { - if (data !== undefined) { - setPresignedUrl(data.data.url); - setFileName(data.data.fileName); - } - }, [data]); - return ( {colorChart === BG_COLOR_CHART && ( diff --git a/src/LecueNote/hooks/useGetPresignedUrl.ts b/src/LecueNote/hooks/useGetPresignedUrl.ts index 3ffeaa7d..573b8471 100644 --- a/src/LecueNote/hooks/useGetPresignedUrl.ts +++ b/src/LecueNote/hooks/useGetPresignedUrl.ts @@ -3,13 +3,20 @@ import { useNavigate } from 'react-router-dom'; import getPresignedUrl from '../api/getPresignedUrl'; -const useGetPresignedUrl = () => { +const useGetPresignedUrl = ( + setPresignedUrl: React.Dispatch>, + setFileName: React.Dispatch>, +) => { const navigate = useNavigate(); const { isLoading, data } = useQuery({ queryKey: ['get-presigned-url'], queryFn: () => getPresignedUrl(), onError: () => navigate('/error'), + onSuccess: (data) => { + setPresignedUrl(data.data.url); + setFileName(data.data.fileName); + }, refetchOnWindowFocus: false, }); From dbc321a0a92ea683faf32924812240704f598497 Mon Sep 17 00:00:00 2001 From: seoAreum <1971236@hansung.ac.kr> Date: Sat, 20 Jan 2024 05:45:00 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20og=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EB=B0=8F=20=ED=83=80=EC=9D=B4=ED=8B=80=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/index.html b/index.html index bc7dc38a..3f6840a4 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,20 @@ + + + + + Lecue