LoadMore
LoadMore renders a sentinel at the end of a list and delegates loading to useInfiniteSentinel. It does not own page data, caching, or virtualization.
import { LoadMore } from '@ilokesto/utilinent';
<LoadMore
onLoadMore={fetchNextPage}
hasMore={hasNextPage}
busy={isFetchingNextPage}
rootMargin="200px"
>
{({ isLoading, isError, retry }) => (
<>
{isLoading ? <span role="status">Loading...</span> : null}
{isError ? <button type="button" onClick={retry}>Retry</button> : null}
</>
)}
</LoadMore>Props and children
All hook options are accepted: required onLoadMore and hasMore, plus busy, disabled, onError, root, rootMargin, and threshold.
children accepts a React node or a render function receiving { isIntersecting, isLoading, isError, error, retry }. It always renders, including while hidden, disabled, or exhausted. Use it to expose a loading announcement, error message, or manual control. No fallback, status announcement, or button behavior is added implicitly.
Use isError to show failure UI, not the truthiness of error. The flag starts as false and becomes true for every thrown or rejected load, including undefined, null, "", false, and 0. error preserves the original unknown reason. Both reset when an eligible new attempt starts; blocked retries leave the failure visible.
busy and hasMore are controlled by the caller. A busy: true to false cycle requests another page if the sentinel remains visible. Returned promises prevent overlapping calls but do not themselves trigger the next page. Thrown/rejected loads stop automatic loading until explicit retry or a new entry; see the hook reference for the full failure and cleanup policy.
Measurable host and proxy tags
The default host is a div, with minHeight: "1px", minWidth: "1px", and display: "block". Empty or completed sentinels keep this box. Consumer style overrides these defaults; avoid display: none, display: contents, or a collapsed box when automatic observation is needed.
<ul>
{items.map((item) => <li key={item.id}>{item.name}</li>)}
<LoadMore.li
onLoadMore={fetchNextPage}
hasMore={hasNextPage}
busy={isFetchingNextPage}
aria-label="Load more items"
/>
</ul>Typed HTML variants such as LoadMore.li, LoadMore.section, and LoadMore.button forward host props and concrete element refs. The default LoadMore forwards a HTMLDivElement ref. A tagged button does not automatically bind a click handler: use the render-prop retry for a manual button.
Proxy registration uses the loadMore category, with the usual base fallback. Custom targets must forward their ref to a measurable HTML element and forward style and other host props. Hook options, including disabled and onError, are consumed rather than forwarded as native host attributes or events.
On the server and without IntersectionObserver, the host and children render normally but automatic loading is inactive. Provide retry as a manual control when needed. Unmount releases the observer without cancelling consumer-owned work.