GitHub

Source

usePagination

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

itemPerPagenumber
trackReferencesTrackReferenceOrPlaceholder[]

Returns

{
totalPageCount: number;
nextPage: () => void;
prevPage: () => void;
setPage: (num: number) => void;
firstItemIndex: number;
lastItemIndex: number;
tracks: TrackReferenceOrPlaceholder[];
currentPage: number;
}