Skip to content

useInfiniteScroll ​

Category
Sensors

Hook that defines the logic for infinite scroll

typescript
import { useInfiniteScroll } from '@siberiacancode/reactuse';

Usage ​

typescript
const { ref, isLoading } = useInfiniteScroll(() => console.log('infinite scroll'));

Demo ​

Api ​

Parameters

NameTypeDefaultNote
callback(event: Event) => void-The callback to execute when a click outside the target is detected
options.distance?number10The distance in pixels to trigger the callback
options.direction?string'bottom'The direction to trigger the callback

Parameters

NameTypeDefaultNote
targetTarget-The target element to detect infinite scroll for
callback(event: Event) => void-The callback to execute when a click outside the target is detected
options.distance?number10The distance in pixels to trigger the callback
options.direction?string'bottom'The direction to trigger the callback

Returns

boolean

Contributors ​

Source • Demo