%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/var/www/html/src/Components/
Upload File :
Create Path :
Current File : //proc/self/root/var/www/html/src/Components/useInView.js

import { useEffect, useRef, useState } from "react";

export const useInView = (ref, options) => {
  const [isIntersecting, setIsIntersecting] = useState(false);
  const observerRef = useRef(null);

  useEffect(() => {
    observerRef.current = new IntersectionObserver(([entry]) => {
      setIsIntersecting(entry.isIntersecting);
    }, options);
  }, []);

  useEffect(() => {
    observerRef.current.observe(ref.current);

    return () => {
      observerRef.current.disconnect();
    };
  }, [ref, options]);

  return isIntersecting;
};

Zerion Mini Shell 1.0