0.0.1 • Published 2 years ago
@ddgrishkin/use-intersection-observer v0.0.1
Use Intersection Observer Hook
Implementation of IntersectionObserver as a hook for using inside React apps.
Example Of Usage
import {useRef, useCallback} from 'react';
import useIntersectionObserver from '@ddgrishkin/use-intersection-observer';
const targetRef = useRef<HTMLElement>(null);
const handleIntersection = useCallback((entries) => {
if (entries[0].isIntersecting) {
// do some stuff
}
}, []);
/* Use it inside react FC */
useIntersectionObserver(targetRef, handleIntersection);
0.0.1
2 years ago