Skip to content

Commit

Permalink
refactor: exhaustive deps 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
WaiNaat committed Oct 14, 2023
1 parent e1f281c commit f29883a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/@common/Toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Toast = (props: ToastItem) => {
setTimeout(() => {
setToastList((prev) => prev.filter(({ id: toastId }) => toastId !== id));
}, 200);
}, []);
}, [id, setToastList]);

const handleClickButton = () => {
onClickButton?.();
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/hooks/@common/useIntersectionRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(<T extends Element>(instance: T | null) => {
if (instance) observer.observe(instance);
}, []);
const intersectionRef = useCallback(
<T extends Element>(instance: T | null) => {
if (instance) observer.observe(instance);
},
[observer]
);

return intersectionRef;
};
Expand Down

0 comments on commit f29883a

Please sign in to comment.