Usage
Options
| Option | Type | Default | Description |
|---|---|---|---|
| hasMore | boolean | - | Whether there is more content to load |
| isLoading | boolean | - | Whether content is currently being loaded |
| onLoadMore | () => void | - | Callback to load more content |
| rootMargin | string | ”100px” | Margin around the root for intersection calculation |
| threshold | number | 0.1 | Visibility threshold to trigger loading |
Returns
| Property | Type | Description |
|---|---|---|
| sentinelRef | RefObject<HTMLDivElement> | Ref to attach to the sentinel element |
Behavior
- Intersection Observer: Uses native browser API for efficient scroll detection
- Load Gating: Only triggers
onLoadMorewhenhasMoreis true andisLoadingis false - Cleanup: Properly disconnects observer on unmount or option changes
Example: With InfiniteContent Component
TheInfiniteContent component uses this hook internally, but you can use the hook directly for custom implementations: