From 6ae274af540e70f4d6af714c2bff6d7ed4920344 Mon Sep 17 00:00:00 2001 From: gyeongza Date: Fri, 28 Jun 2024 18:02:28 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=95=8C=EB=A6=BC=EC=83=81?= =?UTF-8?q?=ED=92=88=20useQuery=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(iTracker)/my/page.tsx | 18 +----------------- src/features/my/api/getFavorites.ts | 6 +++++- src/features/my/hooks/useGetFavorites.ts | 6 +++--- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/app/(iTracker)/my/page.tsx b/src/app/(iTracker)/my/page.tsx index 4daef62..e5dbaeb 100644 --- a/src/app/(iTracker)/my/page.tsx +++ b/src/app/(iTracker)/my/page.tsx @@ -16,23 +16,7 @@ export default function MyPage() { 가격이 변할 때마다 카카오톡 알림을 보내드려요! - - 알림상품을 불러오지 못했어요 - - } - > - - - - } - > - - - + ); } diff --git a/src/features/my/api/getFavorites.ts b/src/features/my/api/getFavorites.ts index 80b9af8..d476990 100644 --- a/src/features/my/api/getFavorites.ts +++ b/src/features/my/api/getFavorites.ts @@ -13,7 +13,11 @@ const getFavoritesUrl = () => `${API_BASE_URL}/api/v1/favorites`; export const getFavorites = async () => { try { - const response = await instance.get(getFavoritesUrl()); + const response = await instance.get(getFavoritesUrl(), { + headers: { + 'Cache-Control': 'no-store', // 서버와 브라우저 모두에 캐시를 저장하지 않도록 설정 + }, + }); return response.data; } catch (e) { diff --git a/src/features/my/hooks/useGetFavorites.ts b/src/features/my/hooks/useGetFavorites.ts index 0dec962..d3176a0 100644 --- a/src/features/my/hooks/useGetFavorites.ts +++ b/src/features/my/hooks/useGetFavorites.ts @@ -1,8 +1,8 @@ -import { UseSuspenseQueryResult, useSuspenseQuery } from '@tanstack/react-query'; +import { useQuery, UseQueryResult } from '@tanstack/react-query'; import { GetFavoritesResponse, getFavorites } from '../api/getFavorites'; -export const useGetFavorites = (): UseSuspenseQueryResult => { - return useSuspenseQuery({ +export const useGetFavorites = (): UseQueryResult => { + return useQuery({ queryKey: ['favorites'], queryFn: getFavorites, });