Skip to content

Commit

Permalink
refactor: 알림상품 useQuery로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
gyeongza committed Jun 28, 2024
1 parent 83db311 commit 6ae274a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
18 changes: 1 addition & 17 deletions src/app/(iTracker)/my/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,7 @@ export default function MyPage() {
가격이 변할 때마다 카카오톡 알림을 보내드려요!
</Text>

<ErrorBoundary
fallback={
<Text typography="small" className="text-badge">
알림상품을 불러오지 못했어요
</Text>
}
>
<Suspense
fallback={
<div className="p-8">
<Loading />
</div>
}
>
<FavoritesList />
</Suspense>
</ErrorBoundary>
<FavoritesList />
</div>
);
}
6 changes: 5 additions & 1 deletion src/features/my/api/getFavorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ const getFavoritesUrl = () => `${API_BASE_URL}/api/v1/favorites`;

export const getFavorites = async () => {
try {
const response = await instance.get<GetFavoritesResponse>(getFavoritesUrl());
const response = await instance.get<GetFavoritesResponse>(getFavoritesUrl(), {
headers: {
'Cache-Control': 'no-store', // 서버와 브라우저 모두에 캐시를 저장하지 않도록 설정
},
});

return response.data;
} catch (e) {
Expand Down
6 changes: 3 additions & 3 deletions src/features/my/hooks/useGetFavorites.ts
Original file line number Diff line number Diff line change
@@ -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<GetFavoritesResponse> => {
return useSuspenseQuery({
export const useGetFavorites = (): UseQueryResult<GetFavoritesResponse> => {
return useQuery({
queryKey: ['favorites'],
queryFn: getFavorites,
});
Expand Down

0 comments on commit 6ae274a

Please sign in to comment.