Interface LazyLoadState<T>

interface LazyLoadState<T> {
    clear: (() => void);
    elements: T[];
    isFetching: boolean;
    loadMore: (() => Promise<void>);
    reachedEnd: boolean;
}

Type Parameters

  • T

Properties

clear: (() => void)

Calling this function resets the hook to its initial state.

elements: T[]

A list of all returned elements. Grows every time loadMore is called until the max amount of elements has been reached.

isFetching: boolean

Boolean flag that indicates whether the hook is currently fetching more items. Can be used to display a load spinner. Gets set to true when loadMore is called and set back to false once it has finished executing.

loadMore: (() => Promise<void>)

Calling this function triggers fetching more items an updating the hook state. Calling this function while isFetching is true, does nothing.

reachedEnd: boolean

Boolean flag that indicates whether all elements have been fetched. Once this flag is true, calling loadMore will have no effect.