Follow-up

This commit is contained in:
Alexander Zinchuk 2023-06-18 16:27:49 +02:00
parent fbda463306
commit a7f79f99d6

View File

@ -170,9 +170,11 @@ export function useIntersectionObserver({
export function useOnIntersect(
targetRef: RefObject<HTMLDivElement>, observe?: ObserveFn, callback?: TargetCallback,
) {
const lastCallback = useLastCallback(callback);
useEffect(() => {
return observe ? observe(targetRef.current!, callback) : undefined;
}, [callback, observe, targetRef]);
return observe ? observe(targetRef.current!, lastCallback) : undefined;
}, [lastCallback, observe, targetRef]);
}
export function useIsIntersecting(