diff --git a/src/pages/mypage/SalesYear.tsx b/src/pages/mypage/SalesYear.tsx index 7036f4b..468af89 100644 --- a/src/pages/mypage/SalesYear.tsx +++ b/src/pages/mypage/SalesYear.tsx @@ -2,17 +2,22 @@ import { useNavigate, useParams } from 'react-router-dom'; import { Topbar } from '../../components/common/Topbar'; import { LineChart } from '../../components/molecules/LineChart'; import { Calculator } from '../../components/molecules/Calculator'; -import { useQuery } from '@tanstack/react-query'; +import { useQuery, useQueryClient } from '@tanstack/react-query'; import { ApiClient } from '../../apis/apiClient'; import { useEffect, useMemo } from 'react'; export const SalesYear = () => { const { year, lesson_id } = useParams<{ year: string; lesson_id: string }>(); const navigate = useNavigate(); + const queryClient = useQueryClient(); + + useEffect(() => { + queryClient.invalidateQueries({ queryKey: ['lessonRevenue', lesson_id] }); + }, [year, lesson_id, queryClient]); // api 호출 const { data: lessonRevenue } = useQuery({ - queryKey: ['monthRevenue', lesson_id], + queryKey: ['lessonRevenue', lesson_id], queryFn: async () => { const response = await ApiClient.getInstance().getLessonRevenue( Number(year),