Skip to content

Commit

Permalink
fix: 좋아요 요청 성공시 리뷰와 꿀조합 상세 쿼리 invalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
Leejin-Yang committed Sep 19, 2023
1 parent 66a2147 commit d26ece6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';

import { recipeApi } from '@/apis';
import type { RecipeFavoriteRequestBody } from '@/types/recipe';
Expand All @@ -10,8 +10,11 @@ const patchRecipeFavorite = (recipeId: number, body: RecipeFavoriteRequestBody)
};

const useRecipeFavoriteMutation = (recipeId: number) => {
const queryClient = useQueryClient();

return useMutation({
mutationFn: (body: RecipeFavoriteRequestBody) => patchRecipeFavorite(recipeId, body),
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['recipeDetail', recipeId] }),
});
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';

import { productApi } from '@/apis';
import type { ReviewFavoriteRequestBody } from '@/types/review';
Expand All @@ -10,8 +10,11 @@ const patchReviewFavorite = (productId: number, reviewId: number, body: ReviewFa
};

const useReviewFavoriteMutation = (productId: number, reviewId: number) => {
const queryClient = useQueryClient();

return useMutation({
mutationFn: (body: ReviewFavoriteRequestBody) => patchReviewFavorite(productId, reviewId, body),
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['product', productId, 'review'] }),
});
};

Expand Down

0 comments on commit d26ece6

Please sign in to comment.