Follow-up
This commit is contained in:
parent
fbda463306
commit
a7f79f99d6
@ -170,9 +170,11 @@ export function useIntersectionObserver({
|
|||||||
export function useOnIntersect(
|
export function useOnIntersect(
|
||||||
targetRef: RefObject<HTMLDivElement>, observe?: ObserveFn, callback?: TargetCallback,
|
targetRef: RefObject<HTMLDivElement>, observe?: ObserveFn, callback?: TargetCallback,
|
||||||
) {
|
) {
|
||||||
|
const lastCallback = useLastCallback(callback);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return observe ? observe(targetRef.current!, callback) : undefined;
|
return observe ? observe(targetRef.current!, lastCallback) : undefined;
|
||||||
}, [callback, observe, targetRef]);
|
}, [lastCallback, observe, targetRef]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useIsIntersecting(
|
export function useIsIntersecting(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user