From 61d331c92d002f4cf601778b5962236d70a1cb75 Mon Sep 17 00:00:00 2001 From: seoAreum <1971236@hansung.ac.kr> Date: Mon, 5 Feb 2024 16:12:20 +0900 Subject: [PATCH 01/16] =?UTF-8?q?fix:=20=EC=96=B8=EB=A7=88=EC=9A=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=8B=9C,=20state=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EB=90=98=EB=8A=94=20=EC=9D=B4=EC=8A=88=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/LecueNote/hooks/useGetPresignedUrl.ts | 34 +++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/LecueNote/hooks/useGetPresignedUrl.ts b/src/LecueNote/hooks/useGetPresignedUrl.ts index 573b8471..4513270b 100644 --- a/src/LecueNote/hooks/useGetPresignedUrl.ts +++ b/src/LecueNote/hooks/useGetPresignedUrl.ts @@ -1,4 +1,4 @@ -import { useQuery } from 'react-query'; +import { useEffect, useRef } from 'react'; import { useNavigate } from 'react-router-dom'; import getPresignedUrl from '../api/getPresignedUrl'; @@ -8,19 +8,29 @@ const useGetPresignedUrl = ( setFileName: React.Dispatch>, ) => { const navigate = useNavigate(); + const isUnmounted = useRef(false); - 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, - }); + useEffect(() => { + isUnmounted.current = false; + const fetchData = async () => { + try { + const { data } = await getPresignedUrl(); - return { isLoading, data }; + setPresignedUrl(data.url); + setFileName(data.fileName); + } catch (error) { + navigate('/error'); + } + }; + + if (!isUnmounted.current) { + fetchData(); + } + + return () => { + isUnmounted.current = true; + }; + }, [navigate, setPresignedUrl, setFileName]); }; export default useGetPresignedUrl; From 9d9340df3fb1e1d32fe11557db8a7fe1aba9183a Mon Sep 17 00:00:00 2001 From: seoAreum <1971236@hansung.ac.kr> Date: Thu, 8 Feb 2024 13:04:53 +0900 Subject: [PATCH 02/16] =?UTF-8?q?fix:=20=EB=85=B8=ED=8A=B8=20=EB=B6=80?= =?UTF-8?q?=EC=B0=A9=20=ED=9B=84=20=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8A=94=20?= =?UTF-8?q?=EA=B3=BC=EC=A0=95=EC=97=90=EC=84=9C=20=EC=A2=85=EC=A2=85=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8D=98=20?= =?UTF-8?q?=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/hooks/useGetPresignedUrl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LecueNote/hooks/useGetPresignedUrl.ts b/src/LecueNote/hooks/useGetPresignedUrl.ts index 4513270b..c07f57bf 100644 --- a/src/LecueNote/hooks/useGetPresignedUrl.ts +++ b/src/LecueNote/hooks/useGetPresignedUrl.ts @@ -30,7 +30,7 @@ const useGetPresignedUrl = ( return () => { isUnmounted.current = true; }; - }, [navigate, setPresignedUrl, setFileName]); + }, []); }; export default useGetPresignedUrl; From 694e56cc6c7b71fc218111fa345f22ab2161b04c Mon Sep 17 00:00:00 2001 From: seoAreum <1971236@hansung.ac.kr> Date: Thu, 8 Feb 2024 13:15:45 +0900 Subject: [PATCH 03/16] =?UTF-8?q?remove:=20props=EB=A7=8C=20=EC=A0=84?= =?UTF-8?q?=EB=8B=AC=ED=95=98=EB=8D=98=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/CreateNote/CreateNote.style.ts | 10 ---- src/LecueNote/components/CreateNote/index.tsx | 51 ------------------- 2 files changed, 61 deletions(-) delete mode 100644 src/LecueNote/components/CreateNote/CreateNote.style.ts delete mode 100644 src/LecueNote/components/CreateNote/index.tsx diff --git a/src/LecueNote/components/CreateNote/CreateNote.style.ts b/src/LecueNote/components/CreateNote/CreateNote.style.ts deleted file mode 100644 index 28ce432b..00000000 --- a/src/LecueNote/components/CreateNote/CreateNote.style.ts +++ /dev/null @@ -1,10 +0,0 @@ -import styled from '@emotion/styled'; - -export const Wrapper = styled.section` - display: flex; - gap: 3.2rem; - flex-direction: column; - - width: 100%; - margin: 7.8rem 0 3.3rem; -`; diff --git a/src/LecueNote/components/CreateNote/index.tsx b/src/LecueNote/components/CreateNote/index.tsx deleted file mode 100644 index 9aaeb42f..00000000 --- a/src/LecueNote/components/CreateNote/index.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { CreateNoteProps } from '../../type/lecueNoteType'; -import SelectColor from '../SelectColor'; -import WriteNote from '../WriteNote'; -import * as S from './CreateNote.style'; - -function CreateNote({ - clickedCategory, - clickedBgColor, - clickedTextColor, - isIconClicked, - contents, - setFileName, - handleChangeFn, - handleClickCategory, - handleClickedColorBtn, - handleClickedIcon, - imgFile, - uploadImage, - binaryImage, - setPresignedUrl, - selectedFile -}: CreateNoteProps) { - return ( - - - - - ); -} - -export default CreateNote; From 52c0f9c957abd8a4140759a83ea643ce632aeefb Mon Sep 17 00:00:00 2001 From: seoAreum <1971236@hansung.ac.kr> Date: Thu, 8 Feb 2024 13:16:10 +0900 Subject: [PATCH 04/16] =?UTF-8?q?chore:=20props=20=EC=A0=84=EB=8B=AC?= =?UTF-8?q?=EC=9A=A9=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C=20->=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../page/LeceuNotePage/LecueNotePage.style.ts | 9 ++++ src/LecueNote/page/LeceuNotePage/index.tsx | 46 +++++++++++-------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/LecueNote/page/LeceuNotePage/LecueNotePage.style.ts b/src/LecueNote/page/LeceuNotePage/LecueNotePage.style.ts index d65164c2..a7bbbf47 100644 --- a/src/LecueNote/page/LeceuNotePage/LecueNotePage.style.ts +++ b/src/LecueNote/page/LeceuNotePage/LecueNotePage.style.ts @@ -11,3 +11,12 @@ export const Wrapper = styled.div` height: 100dvh; padding: 0 1.7rem; `; + +export const CreateNote = styled.section` + display: flex; + gap: 3.2rem; + flex-direction: column; + + width: 100%; + margin: 7.8rem 0 3.3rem; +`; diff --git a/src/LecueNote/page/LeceuNotePage/index.tsx b/src/LecueNote/page/LeceuNotePage/index.tsx index 2d01a324..54b86e2c 100644 --- a/src/LecueNote/page/LeceuNotePage/index.tsx +++ b/src/LecueNote/page/LeceuNotePage/index.tsx @@ -4,8 +4,9 @@ import { useLocation, useNavigate } from 'react-router-dom'; import Header from '../../../components/common/Header'; import LoadingPage from '../../../components/common/LoadingPage'; import CommonModal from '../../../components/common/Modal/CommonModal'; -import CreateNote from '../../components/CreateNote'; import Footer from '../../components/Footer'; +import SelectColor from '../../components/SelectColor'; +import WriteNote from '../../components/WriteNote'; import { BG_COLOR_CHART, CATEGORY, @@ -110,23 +111,32 @@ function LecueNotePage() { headerTitle="레큐노트 작성" handleFn={() => setEscapeModal(true)} /> - setImgFile(file)} - setFileName={setFileName} - handleChangeFn={handleChangeContents} - handleClickCategory={handleClickCategory} - handleClickedColorBtn={handleClickedColorBtn} - handleClickedIcon={handleClickedIcon} - setPresignedUrl={setPresignedUrl} - binaryImage={(file) => setImgFile2(file)} - selectedFile={(file) => setFile(file)} - /> + + + + setImgFile(file)} + binaryImage={(file) => setImgFile2(file)} + setPresignedUrl={setPresignedUrl} + selectedFile={(file) => setFile(file)} + /> + +