diff --git a/src/api/hooks/Mail/useGetMail.tsx b/src/api/hooks/Mail/useGetMail.tsx index c0414e7..768c949 100644 --- a/src/api/hooks/Mail/useGetMail.tsx +++ b/src/api/hooks/Mail/useGetMail.tsx @@ -34,9 +34,13 @@ export const useGetMail = (page: number, size: number, job: string) => { data: mailData, isLoading: mailLoading, isError: mailError, + refetch, } = useQuery({ queryKey: ['emails', page, size, job], queryFn: () => getMail(page, size, job), + enabled: !!job, // job이 존재할 때만 쿼리 실행 + retry: 1, // 에러 시 1번만 재시도 }); - return { mailData, mailLoading, mailError }; + + return { mailData, mailLoading, mailError, refetch }; }; diff --git a/src/pages/MyPage/index.tsx b/src/pages/MyPage/index.tsx index 93eb4f9..8c0366a 100644 --- a/src/pages/MyPage/index.tsx +++ b/src/pages/MyPage/index.tsx @@ -72,7 +72,7 @@ export const MyPage = () => { {mailLoading ? ( ) : mailError ? ( - 오류가 발생했습니다. + 메일이 없습니다! ) : ( mailData?.content.map((email, index) => (