mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 10:55:06 +03:00
19 lines
518 B
TypeScript
19 lines
518 B
TypeScript
import { useEffect } from 'react'
|
|
|
|
interface UseLoadMoreOnIntersectParams {
|
|
readonly isIntersecting: boolean | undefined
|
|
readonly canLoadMore: boolean
|
|
readonly loadMore: () => void
|
|
}
|
|
|
|
/** Calls `loadMore` whenever the sentinel is intersecting and more can be loaded. */
|
|
export const useLoadMoreOnIntersect = ({
|
|
isIntersecting,
|
|
canLoadMore,
|
|
loadMore,
|
|
}: UseLoadMoreOnIntersectParams) => {
|
|
useEffect(() => {
|
|
if (isIntersecting && canLoadMore) loadMore()
|
|
}, [isIntersecting, canLoadMore, loadMore])
|
|
}
|