From f29883a5c86ac2107241fc296f49d6b13ba6d2ef Mon Sep 17 00:00:00 2001 From: WaiNaat Date: Sun, 15 Oct 2023 00:54:51 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20exhaustive=20deps=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/@common/Toast/index.tsx | 2 +- frontend/src/hooks/@common/useIntersectionRef.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/@common/Toast/index.tsx b/frontend/src/components/@common/Toast/index.tsx index 515584c6d..9c24cf500 100644 --- a/frontend/src/components/@common/Toast/index.tsx +++ b/frontend/src/components/@common/Toast/index.tsx @@ -39,7 +39,7 @@ const Toast = (props: ToastItem) => { setTimeout(() => { setToastList((prev) => prev.filter(({ id: toastId }) => toastId !== id)); }, 200); - }, []); + }, [id, setToastList]); const handleClickButton = () => { onClickButton?.(); diff --git a/frontend/src/hooks/@common/useIntersectionRef.ts b/frontend/src/hooks/@common/useIntersectionRef.ts index ef188250b..2ac264231 100644 --- a/frontend/src/hooks/@common/useIntersectionRef.ts +++ b/frontend/src/hooks/@common/useIntersectionRef.ts @@ -2,11 +2,14 @@ import { useCallback, useMemo } from 'react'; import createObserver from 'utils/createObserver'; const useIntersectionRef = (onIntersecting: () => void) => { - const observer = useMemo(() => createObserver(onIntersecting), []); + const observer = useMemo(() => createObserver(onIntersecting), [onIntersecting]); - const intersectionRef = useCallback((instance: T | null) => { - if (instance) observer.observe(instance); - }, []); + const intersectionRef = useCallback( + (instance: T | null) => { + if (instance) observer.observe(instance); + }, + [observer] + ); return intersectionRef; };