From 810a3c75581b916eac1eb71c73d317ff0ec7f8a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8C=E1=85=A5=E1=86=BC?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Wed, 1 Nov 2023 00:45:06 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Feat:=20react-query=20refetch=ED=95=A0=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EB=8A=94=20=ED=95=A8=EC=88=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/providers/ProfileProvider.tsx | 5 +++++ src/contexts/ProfileContext.tsx | 1 + 2 files changed, 6 insertions(+) diff --git a/src/components/providers/ProfileProvider.tsx b/src/components/providers/ProfileProvider.tsx index 5e694814..4ffec413 100644 --- a/src/components/providers/ProfileProvider.tsx +++ b/src/components/providers/ProfileProvider.tsx @@ -47,6 +47,10 @@ const ProfileProvider = ({ children }: ProfileProviderProps) => { } }, [profileQuery.data]); + const refetchProfile = async () => { + await profileQuery.refetch(); + }; + return ( { setProfile, status: profileQuery.status, isInitialLoading: profileQuery.isInitialLoading, + refetchProfile, }} > {children} diff --git a/src/contexts/ProfileContext.tsx b/src/contexts/ProfileContext.tsx index aa85ea05..8de151af 100644 --- a/src/contexts/ProfileContext.tsx +++ b/src/contexts/ProfileContext.tsx @@ -7,6 +7,7 @@ interface ProfileState { setProfile: React.Dispatch>; status: 'loading' | 'error' | 'success'; isInitialLoading: boolean; + refetchProfile: () => Promise; } const ProfileContext = createContext(null); From 8cf671abb057b46d71a6e73ac265cd7126761a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=8C=E1=85=A5=E1=86=BC?= =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=A8?= Date: Wed, 1 Nov 2023 00:46:55 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Feat:=20=EB=A1=9C=EA=B7=B8=EC=95=84?= =?UTF-8?q?=EC=9B=83=20api=20=EC=9A=94=EC=B2=AD=20=EC=84=B1=EA=B3=B5?= =?UTF-8?q?=EC=8B=9C=20profile=20refetch=20=EB=B0=8F=20=EB=A3=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=9C=20push?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Header/Header.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index fec0aa2c..d3cb3048 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -36,6 +36,7 @@ const Header = () => { Cookies.remove('accessToken'); Cookies.remove('refreshToken'); + await profileContext?.refetchProfile(); router.push('/'); } catch (error) { alert('로그아웃에 실패하였습니다.\n다시 시도해주세요');