useInfiniteScroll

useInfiniteScroll is a custom hook that provides infinite scroll functionality.

Usage

import { useInfiniteScroll } from "@yamada-ui/react"
const { ref, finish } = useInfiniteScroll()

Specify the Viewport

To specify the viewport, set a ref to rootRef.

Set rootMargin

To set rootMargin, assign a string to rootMargin.

Set threshold

To set threshold, assign a number to threshold.

Initial Load

To load initially, set initialLoad to true. By default, initialLoad is set to false, and the initial(index=0) onLoad is not executed.

true: The first onLoad is executed regardless of the scroll amount, and the provided index starts from 0.
false: onLoad is executed when a certain scroll is reached, and the provided index starts from 1.

Change the Starting index

To change the starting index, set a number to startIndex. The default is 1.

Reverse

To reverse, set reverse to true. The default is false.