From 6b7828ede7a774c3e85788a82c15f0a5bb6374d5 Mon Sep 17 00:00:00 2001 From: seo0o519 Date: Tue, 28 May 2024 16:04:31 +0900 Subject: [PATCH] Chore: reset recoil when logout or del account #125 --- src/pages/MypagePage.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pages/MypagePage.js b/src/pages/MypagePage.js index ef9d041..5f4684b 100644 --- a/src/pages/MypagePage.js +++ b/src/pages/MypagePage.js @@ -15,6 +15,8 @@ import DoDisturbOutlinedIcon from "@mui/icons-material/DoDisturbOutlined"; import CancelContent from "../components/common/CancelContent"; import BottomNav from "../layout/BottomNav"; import axios from "axios"; +import { useRecoilState } from "recoil"; +import { tripNameState, tripIdState, diaryIdState } from "../recoil/commonState"; const MypagePage = () => { //axios get으로 받아온 username location으로 전달 @@ -22,6 +24,9 @@ const MypagePage = () => { const [isModalOpen, setIsModalOpen] = useState(false); const [message, setMessage] = useState(""); const [userInfo, setUserInfo] = useState({ name: "", email: "", profileimg: "" }); + const [tripName, setTripName] = useRecoilState(tripNameState); + const [tripId, setTripId] = useRecoilState(tripIdState); + const [diaryID, setDiaryId] = useRecoilState(diaryIdState); const toggleModal = () => { console.log(isModalOpen); @@ -75,6 +80,9 @@ const MypagePage = () => { .then((response) => { const status = response.status; if (status === 200) { + setTripName(""); + setTripId(""); + setDiaryId(""); setMessage("로그아웃 성공"); } else if (status === 401) { setMessage("로그인이 필요합니다."); @@ -95,6 +103,9 @@ const MypagePage = () => { const status = response.status; console.log("res",status); if (status === 200) { + setTripName(""); + setTripId(""); + setDiaryId(""); setMessage("계정이 성공적으로 삭제되었습니다."); } else if (status === 404) { setMessage("사용자를 찾을 수 없습니다.");