From 939318a909f17d1faafb2115f097036ff824734a Mon Sep 17 00:00:00 2001 From: sunhpark42 Date: Sun, 6 Feb 2022 12:37:03 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=A1=B0=ED=9A=8C=EC=88=98=EA=B0=80=202?= =?UTF-8?q?=EC=94=A9=20=EC=A6=9D=EA=B0=80=ED=95=98=EB=8A=94=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/StudylogPage/index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/StudylogPage/index.js b/frontend/src/pages/StudylogPage/index.js index 3c0525b8b..580fb4706 100644 --- a/frontend/src/pages/StudylogPage/index.js +++ b/frontend/src/pages/StudylogPage/index.js @@ -10,7 +10,7 @@ import { ButtonList, EditButtonStyle, DeleteButtonStyle } from './styles'; import { MainContentStyle } from '../../PageRouter'; import { UserContext } from '../../contexts/UserProvider'; import useSnackBar from '../../hooks/useSnackBar'; -import useRequest from '../../hooks/useRequest'; +import useStudylog from '../../hooks/useStudylog'; import useMutation from '../../hooks/useMutation'; import debounce from '../../utils/debounce'; @@ -18,7 +18,6 @@ import { requestPostScrap, requestDeleteScrap, requestDeleteLike, - requestGetStudylog, requestDeleteStudylog, requestPostLike, } from '../../service/requests'; @@ -40,9 +39,8 @@ const StudylogPage = () => { const { openSnackBar } = useSnackBar(); - const { response: studylog, fetchData: getStudylog } = useRequest({}, () => - requestGetStudylog({ id, accessToken }) - ); + const { response: studylog, getData } = useStudylog({}); + const getStudylog = () => getData({ id, accessToken }); const { mutate: deleteStudylog } = useMutation( () => { @@ -157,7 +155,12 @@ const StudylogPage = () => { }; useEffect(() => { - getStudylog(); + // accessToken 이 있을 시에 studylogs -> me -> studylogs 순서 제어를 위한 임시 코드 + const timeout = setTimeout(() => getStudylog(), 0); + + return () => { + clearTimeout(timeout); + }; }, [accessToken, id]); return (