@tremendous/help
    Preparing search index...

    Function useInfinityScroll

    • Custom hook that triggers a callback when the user scrolls to the bottom of an element.

      This hook adds an event listener to an element that checks if the user has scrolled to the bottom. When the bottom is reached, it triggers the provided callback function.

      Parameters

      • element: HTMLElement | null

        The target element to attach the scroll event listener to.

      • callback: () => void

        The function to call when the user scrolls to the bottom.

      • dependencies: DependencyList

        A list of dependencies for the effect.

      Returns void

      const divRef = useRef<HTMLDivElement>(null);
      useInfinityScroll(divRef.current, [], () => {
      console.log('Scrolled to the bottom!');
      });