s-private API Documentation - v3.8.1
    Preparing search index...

    Function useInfiniteScroll

    • Hook for implementing infinite scroll with Intersection Observer.

      Parameters

      Returns UseInfiniteScrollReturn

      Object containing ref callback for the last element

      Automatically loads more content when the last element becomes visible. Uses IntersectionObserver for efficient scroll detection.

      Features:

      • Automatic fetch when last element is visible
      • Prevents duplicate fetches during loading
      • SSR-safe with delayed initialization
      • Configurable root margin and threshold
      function ItemList({ items, hasMore, fetchMore }) {
      const { lastElementRef } = useInfiniteScroll({
      hasNextPage: hasMore,
      isFetchingNextPage: false,
      fetchNextPage: fetchMore,
      });

      return (
      <ul>
      {items.map((item, i) => (
      <li
      key={item.id}
      ref={i === items.length - 1 ? lastElementRef : null}
      >
      {item.name}
      </li>
      ))}
      </ul>
      );
      }