From e116ec06cbdc4e5c25442ee201c31a53eac0b4b0 Mon Sep 17 00:00:00 2001 From: lee gyu yeol-mac Date: Wed, 20 Nov 2024 14:54:37 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9A=8C=EC=9B=90=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/components/Header.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/components/Header.tsx b/src/pages/components/Header.tsx index 3cd924e..d116116 100644 --- a/src/pages/components/Header.tsx +++ b/src/pages/components/Header.tsx @@ -1,6 +1,6 @@ import styles from "./LoggedInHeader.module.css"; import { logout, getUser } from "@/services/api"; -import { useQuery, useMutation } from "@tanstack/react-query"; +import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import { useAccessRightStore } from "@/store/accessRight"; import { Link, NavLink, useNavigate, useParams } from "react-router-dom"; @@ -11,10 +11,10 @@ const LoggedInHeader = () => { const params = useParams(); let isFixed = false; let isInClassroomDashboarclassroomdUrl = false; - + const queryClient = useQueryClient(); const isHost = useAccessRightStore((state) => state.isHost); const classroomId = Number(params.classroomId); - const { data: userData, refetch } = useQuery({ + const { data: userData } = useQuery({ queryKey: ["user"], queryFn: getUser, staleTime: 1000 * 60, @@ -34,9 +34,9 @@ const LoggedInHeader = () => { // 로그아웃 mutation const logoutMuation = useMutation({ mutationFn: logout, - onSuccess: () => { + onSuccess: async () => { // 로그아웃 시 user 쿼리 캐시를 null로 설정 - refetch(); + await queryClient.invalidateQueries(); navigate("/"); }, onError: (error) => { @@ -119,7 +119,7 @@ const LoggedInHeader = () => {

로그아웃

- + )}