From fba92b9158198433eeab147619d7181686542680 Mon Sep 17 00:00:00 2001 From: kuku Date: Wed, 21 Dec 2022 19:21:23 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20=EC=A0=95=EB=A0=AC=20=EA=B2=80=EC=83=89?= =?UTF-8?q?=20=ED=95=A8=EC=88=98=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/pages/mainPages/AllThemePage.jsx | 17 ++++++++++------- front/src/pages/mainPages/RestaurantPage.jsx | 15 ++++++++------- front/src/pages/mainPages/SpotPage.jsx | 15 ++++++++------- front/src/pages/mainPages/StayPage.jsx | 15 ++++++++------- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/front/src/pages/mainPages/AllThemePage.jsx b/front/src/pages/mainPages/AllThemePage.jsx index bf44e213..9b04ff68 100644 --- a/front/src/pages/mainPages/AllThemePage.jsx +++ b/front/src/pages/mainPages/AllThemePage.jsx @@ -29,16 +29,19 @@ function AllThemePage() { sort, ); + const resethandler = () => { + setPosts([]); + setLastData(''); + target.current.style.display = 'flex'; + }; + const sortHandler = sorted => { - console.log(sorted); if (sort !== sorted) { setSort(sorted); } - if (posts.length !== 0) { - setPosts([]); - } - setLastData(''); - target.current.style.display = 'flex'; + resethandler(); + // if (posts.length !== 0) { + // } }; useEffect(() => { @@ -46,7 +49,7 @@ function AllThemePage() { }, [sort, search]); useEffect(() => { - sortHandler(sort); + resethandler(); }, [search]); useEffect(() => { diff --git a/front/src/pages/mainPages/RestaurantPage.jsx b/front/src/pages/mainPages/RestaurantPage.jsx index 82cfa5d8..63de6d14 100644 --- a/front/src/pages/mainPages/RestaurantPage.jsx +++ b/front/src/pages/mainPages/RestaurantPage.jsx @@ -32,16 +32,17 @@ function RestaurantPage() { sort, ); + const resethandler = () => { + setPosts([]); + setLastData(''); + target.current.style.display = 'flex'; + }; + const sortHandler = sorted => { - console.log(sorted); if (sort !== sorted) { setSort(sorted); } - if (posts.length !== 0) { - setPosts([]); - } - setLastData(''); - target.current.style.display = 'flex'; + resethandler(); }; useEffect(() => { @@ -49,7 +50,7 @@ function RestaurantPage() { }, [sort, search]); useEffect(() => { - sortHandler(sort); + resethandler(); }, [search]); useEffect(() => { diff --git a/front/src/pages/mainPages/SpotPage.jsx b/front/src/pages/mainPages/SpotPage.jsx index 59b0eb25..7ecc43d9 100644 --- a/front/src/pages/mainPages/SpotPage.jsx +++ b/front/src/pages/mainPages/SpotPage.jsx @@ -29,16 +29,17 @@ function SpotPage() { sort, ); + const resethandler = () => { + setPosts([]); + setLastData(''); + target.current.style.display = 'flex'; + }; + const sortHandler = sorted => { - console.log(sorted); if (sort !== sorted) { setSort(sorted); } - if (posts.length !== 0) { - setPosts([]); - } - setLastData(''); - target.current.style.display = 'flex'; + resethandler(); }; useEffect(() => { @@ -46,7 +47,7 @@ function SpotPage() { }, [sort, search]); useEffect(() => { - sortHandler(sort); + resethandler(); }, [search]); useEffect(() => { diff --git a/front/src/pages/mainPages/StayPage.jsx b/front/src/pages/mainPages/StayPage.jsx index 225a1c10..4e820677 100644 --- a/front/src/pages/mainPages/StayPage.jsx +++ b/front/src/pages/mainPages/StayPage.jsx @@ -29,16 +29,17 @@ function StayPage() { sort, ); + const resethandler = () => { + setPosts([]); + setLastData(''); + target.current.style.display = 'flex'; + }; + const sortHandler = sorted => { - console.log(sorted); if (sort !== sorted) { setSort(sorted); } - if (posts.length !== 0) { - setPosts([]); - } - setLastData(''); - target.current.style.display = 'flex'; + resethandler(); }; useEffect(() => { @@ -46,7 +47,7 @@ function StayPage() { }, [sort, search]); useEffect(() => { - sortHandler(sort); + resethandler(); }, [search]); useEffect(() => {