usePagination
Note
This feature is experimental and may change or be removed based on developer feedback and real-world usage.
The usePagination
hook implements simple pagination logic for use with arrays.
Import
import { usePagination } from "@livekit/components-react";
Usage
const tracks = useTracks();const pagination = usePagination(4, tracks);<TrackLoop tracks={pagination.tracks} />;
Properties
Returns
{totalPageCount: number;nextPage: () => void;prevPage: () => void;setPage: (num: number) => void;firstItemIndex: number;lastItemIndex: number;tracks: TrackReferenceOrPlaceholder[];currentPage: number;}