Skip to main content

Interface: VirtuosoMessageListMethods<Data, Context>

The imperative API of the message list component. You can access it with a ref, or by using the useVirtuosoMethods() hook from a child component.

Type parameters

NameTypeDescription
DataanyThe type of the data items in the list. Specifying this type gives you correct typing in the data methods.
ContextanyThe type of the context passed to the list. Specifying this type gives you correct typing in the data methods.

Properties

data

data: Object

A set of methods to manipulate the data in the list.

Type declaration

NameTypeDescription
prepend(data: Data[]) => void-
append(data: Data[], scrollToBottom?: AutoscrollToBottom<Data, Context>) => void-
map(callbackfn: (data: Data, index: number) => Data, autoscrollToBottomBehavior?: "auto" | "smooth") => void-
findAndDelete(predicate: (item: Data, index: number) => boolean) => void-
findIndex(predicate: (item: Data, index: number, data: Data[]) => boolean) => number-
find(predicate: (item: Data, index: number, data: Data[]) => boolean) => Data-
replace(data: Data[], initialLocation?: ItemLocation) => void-

scrollToItem

scrollToItem: (item: ItemLocation) => void

Scrolls the list to the specified item. See ItemLocation for possible location details. Passing a number scrolls to the item at the specified index aligned to the top.

Type declaration

▸ (item): void

Parameters
NameType
itemItemLocation
Returns

void


scrollerElement

scrollerElement: () => HTMLDivElement

Lets you obtain a reference to the component's scroller DOM element.

Type declaration

▸ (): HTMLDivElement

Returns

HTMLDivElement