From c7b0d262bc93e769720927d57625f719e532f661 Mon Sep 17 00:00:00 2001 From: a-honey Date: Wed, 28 Feb 2024 03:11:50 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=AC=B4=ED=95=9C=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A1=A4=20=EB=AF=B8=EB=B0=98=EC=98=81=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=BA=90=EC=8B=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/organisms/FridgeBoard.tsx | 6 +++--- src/components/organisms/IngredientModal.tsx | 4 +++- src/hooks/queries/fridge/useGetFridgeContentById.ts | 3 ++- src/hooks/queries/fridge/usePostFridge.ts | 1 - src/hooks/queries/useBaseInfiniteQuery.ts | 7 +++++-- src/pages/_app.tsx | 1 + 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/organisms/FridgeBoard.tsx b/src/components/organisms/FridgeBoard.tsx index 71b292f..7a5200e 100644 --- a/src/components/organisms/FridgeBoard.tsx +++ b/src/components/organisms/FridgeBoard.tsx @@ -92,9 +92,9 @@ const FridgeBoard: React.FC = () => { handleTabNameChange={handleTabNameChange} />
- {ingredients?.pages.map((page) => - page.content && page.content.length > 0 ? ( - page.content.map((ingredient) => ( + {ingredients?.pages.map(({ content }) => + content && content.length > 0 ? ( + content.map((ingredient) => ( { toggleIsOpenIngredientModal(); - ingredientsRefetch(); showToast('식자재 추가가 완료되었습니다.', 'success'); + ingredientsRefetch(); + queryClient.invalidateQueries({ queryKey: ['my_fridge'] }); }; const postIngredient = usePostIngredient( diff --git a/src/hooks/queries/fridge/useGetFridgeContentById.ts b/src/hooks/queries/fridge/useGetFridgeContentById.ts index 9345911..e59661b 100644 --- a/src/hooks/queries/fridge/useGetFridgeContentById.ts +++ b/src/hooks/queries/fridge/useGetFridgeContentById.ts @@ -20,11 +20,12 @@ const useGetFridgeContentById = ({ sort: LocationEnum; id: number; }) => { - return useBaseInfiniteQuery({ + const data = useBaseInfiniteQuery({ queryKey: queryKeys.MY_FRIDGE_CONTENT(id, sort), url: `/ingrs/detail/refrig/${id}`, params: { location: sort }, }); + return data; }; export default useGetFridgeContentById; diff --git a/src/hooks/queries/fridge/usePostFridge.ts b/src/hooks/queries/fridge/usePostFridge.ts index 30f5774..131831b 100644 --- a/src/hooks/queries/fridge/usePostFridge.ts +++ b/src/hooks/queries/fridge/usePostFridge.ts @@ -8,7 +8,6 @@ interface PostFridgeBodyType { const usePostFridge = () => { const onSuccess = (data: PostFridgeBodyType) => { - console.log(data); void queryClient.invalidateQueries(); }; return useBaseMutation( diff --git a/src/hooks/queries/useBaseInfiniteQuery.ts b/src/hooks/queries/useBaseInfiniteQuery.ts index 7757855..f6d874a 100644 --- a/src/hooks/queries/useBaseInfiniteQuery.ts +++ b/src/hooks/queries/useBaseInfiniteQuery.ts @@ -43,9 +43,12 @@ export const useBaseInfiniteQuery = ({ return useInfiniteQuery({ queryKey, - queryFn: async (context: QueryFunctionContext) => - await fetchData(context), + queryFn: async (context: QueryFunctionContext) => { + const data = await fetchData(context); + return data; + }, initialPageParam: INITIAL_PAGE_PARAM, getNextPageParam: (res) => getNextOffset(res), + staleTime: 0, }); }; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 47f5788..9d73b61 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -25,6 +25,7 @@ export const queryClient = new QueryClient({ defaultOptions: { queries: { staleTime: 0, + gcTime: 0, retry: false, refetchOnWindowFocus: false, },