function useInfiniteScroll
useInfiniteScroll(
onLoadMore: () => void,
enabled: boolean
): (node: HTMLDivElement | null) => void

Returns a callback ref for the sentinel element placed after a feed's last item, and calls onLoadMore when the sentinel comes within 200px of the view while enabled. Feed pages pass canLoadMore of their list.

The ref is a callback so that the observer follows a new sentinel, as when Index switches tabs and another feed mounts its own.

A sentinel still in view after a load asks again, which fills a tall screen, but would also retry a failing request as fast as it fails. So while it stays in view the waits double, from 1s up to 30s, and they start over once it leaves the view or new items push it down.

Parameters

onLoadMore: () => void
enabled: boolean

Return Type

(node: HTMLDivElement | null) => void

Usage

import { useInfiniteScroll } from "src/hooks/feed/useInfiniteScroll.ts";