0.0.1 • Published 2 years ago

@ddgrishkin/use-intersection-observer v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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);