From d870eb89d1af60894b415f6aa932832b9bc48e7a Mon Sep 17 00:00:00 2001 From: Sungjun Kim <90247223+kim-song-jun@users.noreply.github.com> Date: Thu, 7 Aug 2025 00:41:40 +0900 Subject: [PATCH] refactor: consolidate order cooking refresh effect --- src/pages/orders/OrderCookingPage.tsx | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/pages/orders/OrderCookingPage.tsx b/src/pages/orders/OrderCookingPage.tsx index 8fa19b8..0dfc216 100644 --- a/src/pages/orders/OrderCookingPage.tsx +++ b/src/pages/orders/OrderCookingPage.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef } from 'react'; +import { useEffect } from 'react'; import { useCookingOrder } from '@/stores/orders/cookingOrder'; import IconNotFound from '@/components/icons/IconNotFound'; import OrderCookingCard from '@/components/orders/OrderCookingCard'; @@ -13,31 +13,17 @@ const OrderCookingPage: React.FC = () => { getCookingOrderList, } = useCookingOrder(); - const intervalRef = useRef(null); - useEffect(() => { if (!boothId) return; getCookingOrderList({ boothId, date: nowDate }); - intervalRef.current = setInterval(() => { - getCookingOrderList({ boothId, date: nowDate }); - }, 3000); - - return () => { - if (intervalRef.current) { - clearInterval(intervalRef.current); - } - }; - }, [boothId, nowDate]); - - useEffect(() => { const interval = setInterval(() => { getCookingOrderList({ boothId, date: nowDate }); }, 2000); // 2초 간격으로 서버에서 최신 조리 현황 받아오기 return () => clearInterval(interval); - }, []); + }, [boothId, nowDate]); return ( <>