From b4b81246908e408c5677643d1c7fcb961c752b03 Mon Sep 17 00:00:00 2001 From: seoyeon08 Date: Mon, 8 Jul 2024 13:28:04 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=81=B4=EB=9E=98=EC=8A=A4=EB=B3=84=20?= =?UTF-8?q?=EB=A7=A4=EC=B6=9C=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B7=B8?= =?UTF-8?q?=EB=9E=98=ED=94=84-=EC=BF=BC=EB=A6=AC=20=EB=AC=B4=ED=9A=A8?= =?UTF-8?q?=ED=99=94=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/mypage/SalesYear.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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),