Skip to main content

Interface: DataMethods<Data, Context>

Type parameters

NameType
Dataany
Contextany

Properties

prepend

prepend: (data: Data[]) => void

Prepends additional items to the existing data in the list, while preserving the scroll position.

Type declaration

▸ (data): void

Parameters
NameTypeDescription
dataData[]The data to prepend.
Returns

void


append

append: (data: Data[], scrollToBottom?: AutoscrollToBottom<Data, Context>) => void

Appends additional items to the existing data in the list, while optionally updating the scroll position. See the AutoscrollToBottom type for more information.

Type declaration

▸ (data, scrollToBottom?): void

Parameters
NameTypeDescription
dataData[]The data to append.
scrollToBottom?AutoscrollToBottom<Data, Context>Specifies the behavior when the list is scrolled to the bottom. You can pass a boolean, a ScrollBehavior, or a function that returns a ScrollBehavior.
Returns

void


map

map: (callbackfn: (data: Data, index: number) => Data, autoscrollToBottomBehavior?: "auto" | "smooth") => void

Updates the data in the list by applying a mapping function to each item. Optionally, you can specify a scroll behavior if the state change displaces the list (for example, if the item size increases).

Type declaration

▸ (callbackfn, autoscrollToBottomBehavior?): void

Parameters
NameTypeDescription
callbackfn(data: Data, index: number) => DataA function that maps the data items.
autoscrollToBottomBehavior?"auto" | "smooth"Specifies the behavior to use to scroll to the bottom if necessary.
Returns

void


findAndDelete

findAndDelete: (predicate: (item: Data, index: number) => boolean) => void

Deletes items from the list data that match the predicate.

Type declaration

▸ (predicate): void

Parameters
NameType
predicate(item: Data, index: number) => boolean
Returns

void


findIndex

findIndex: (predicate: (item: Data, index: number, data: Data[]) => boolean) => number

Finds the index of the first item that matches the predicate. If no elements satisfy the testing function, -1 is returned.

Type declaration

▸ (predicate): number

Parameters
NameType
predicate(item: Data, index: number, data: Data[]) => boolean
Returns

number


find

find: (predicate: (item: Data, index: number, data: Data[]) => boolean) => Data

Finds the first item that matches the predicate. If no elements satisfy the testing function, undefined is returned.

Type declaration

▸ (predicate): Data

Parameters
NameType
predicate(item: Data, index: number, data: Data[]) => boolean
Returns

Data


replace

replace: (data: Data[], options?: { initialLocation?: ItemLocation ; purgeItemSizes?: boolean }) => void

Completely replaces the data in the list with the new data. Optionally, you can specify an initial scroll location after the data has been replaced. See the ItemLocation type for more information.

Type declaration

▸ (data, options?): void

Parameters
NameTypeDescription
dataData[]The data to replace.
options?Objectthe location to scroll to after the data has been replaced and whether to purge the item sizes.
options.initialLocation?ItemLocation-
options.purgeItemSizes?boolean-
Returns

void


insert

insert: (data: Data[], offset: number, scrollToBottom?: AutoscrollToBottom<Data, Context>) => void

Inserts the provided data at the specified offset, optionally updating the scroll position.

Type declaration

▸ (data, offset, scrollToBottom?): void

Parameters
NameTypeDescription
dataData[]The data to append.
offsetnumberThe index that the first item in the data will be inserted at. e.g. [1,2,3] with offset 10 will insert the data at index 10, 11, and 12 and shift the rest of the existing data.
scrollToBottom?AutoscrollToBottom<Data, Context>Specifies the behavior when the list is scrolled to the bottom. You can pass a boolean, a ScrollBehavior, or a function that returns a ScrollBehavior.
Returns

void


deleteRange

deleteRange: (offset: number, count: number) => void

Deletes a range of items from the list data.

Type declaration

▸ (offset, count): void

Parameters
NameTypeDescription
offsetnumberThe index of the first item to delete.
countnumberThe number of items to delete.
Returns

void


batch

batch: (callback: () => void, scrollToBottom?: AutoscrollToBottom<Data, Context>) => void

Batches the data operations in the provided callback in a single render cycle.

Type declaration

▸ (callback, scrollToBottom?): void

Parameters
NameTypeDescription
callback() => voidThe callback that performs the data operations.
scrollToBottom?AutoscrollToBottom<Data, Context>Specifies the behavior when the list is scrolled to the bottom. You can pass a boolean, a ScrollBehavior, or a function that returns a ScrollBehavior.
Returns

void


get

get: () => Data[]

Gets a shallow copy of the current data in the list.

Type declaration

▸ (): Data[]

Returns

Data[]


getCurrentlyRendered

getCurrentlyRendered: () => Data[]

Gets the currently rendered data items.

Type declaration

▸ (): Data[]

Returns

Data[]