Skip to content

useInfiniteScroll ​

sensors
test coverage
Last changed: 24 days ago

Hook that defines the logic for infinite scroll

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

Usage ​

typescript
const { ref, loading } = useInfiniteScroll(() => console.log('infinite scroll'));
// or
const loading = useInfiniteScroll(ref, () => 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
targetHookTarget-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

Source ​

Source β€’ Demo

Contributors ​

Avatardebabin
Avatarβ€œEdiand11”
AvatarNikita

Released under the MIT License.