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(() => {