Skip to content

ddgrishkin/use-intersection-observer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published