Lynx/Modules/List/API reference
@sigx/lynx-list · Beta

API reference#

Exports of @sigx/lynx-list v0.12.2.

Exports#

ExportKindPurpose
ListcomponentThe virtualized list.
ListMethodsobjectImperative scroll methods for a captured element.
ListProps<T>typeProps of List, generic over the item type.
ListReftypeThe mtRef type — a main-thread ref to the native element.
ListTypetype'single' | 'flow' | 'waterfall'.
ListItemSnaptype'start' | 'center' | 'end' | 'none'.
ScrollAligntype'top' | 'bottom' | 'middle'.
ScrollToIndexOptionstypeOptions for ListMethods.scrollToIndex.
TSX
import { List, ListMethods } from '@sigx/lynx-list';
import type { ListProps, ListRef } from '@sigx/lynx-list';

<List> props#

items and renderItem are the only required props; both are generic over the element type T of items.

PropTypeNotes
itemsreadonly T[]Required. The data.
renderItem(item: T, index: number) => JSXRequired. Per-cell renderer.
keyExtractor(item: T, index: number) => stringStable recycler key (item-key). Defaults to the index — set it for lists that mutate.
itemType(item: T, index: number) => stringRecycle-pool selector (item-type) for mixed cell shapes.
estimatedItemSizenumberMain-axis px estimate for uniform rows; improves scroll accuracy. Omit for variable-height content (chat) — a too-small estimate clips items until measured.
horizontalbooleanHorizontal scrolling.
numColumnsnumberGrid columns (span-count).
listTypeListTypeLayout mode: single (default), flow, waterfall.
itemSnapListItemSnapPaginated snap: start / center / end / none.
onEndReachedThresholdnumberItems-from-end at which onEndReached fires.
onStartReachedThresholdnumberItems-from-start at which onStartReached fires.
loadingMorebooleanShow a trailing loading cell (infinite scroll).
refreshingbooleanControlled pull-to-refresh state; passing it opts in (vertical only).
pullThresholdnumberPull distance (px) that triggers a refresh. Default 64.
invertedbooleanChat mode: bottom-anchored + stick-to-bottom (vertical only).
stickToBottombooleanIn chat mode, auto-scroll on new items when at the bottom. Default true.
windowSizenumberEnables windowing: render only this many cells of a long items.
pageSizenumberItems revealed per scroll-edge page when windowing. Default 30.
maxWindownumberCap on rendered window length; the far end trims past it. Default max(120, windowSize × 2).
mtRefListRefCapture the native element for ListMethods.
class / styleApplied to the measuring wrapper <view>.

Events#

EventPayloadFires
onEndReachedWithin onEndReachedThreshold items of the end.
onStartReachedWithin onStartReachedThreshold items of the start.
onScroll{ offset: number }On scroll, with the current offset.
onRefreshOn a pull-to-refresh past pullThreshold.

Slots#

Passed through the slots prop.

SlotSignatureRenders
header() => JSXA full-span cell before the items.
footer() => JSXA full-span cell after the items.
empty() => JSXIn place of the list when items is empty.
refresh() => JSXCustom pull-to-refresh indicator.
newMessages({ count }) => JSXChat-mode "new messages" affordance while scrolled up.

ListMethods#

Typed wrappers around the native scroll UI methods, callable from any main-thread event handler. Both accept el | null, so you can pass ref.current directly; a null element is a silent no-op.

TSX
ListMethods.scrollToTop(el);                          // jump to top
ListMethods.scrollToTop(el, { smooth: true });        // animated
ListMethods.scrollToIndex(el, 12, { align: 'middle', smooth: true });
  • scrollToTop(el, opts?) — scroll to the first cell (the top of the list, header included).
  • scrollToIndex(el, index, opts?) — scroll so the cell at index aligns per opts.align. index is the rendered cell index, not the data index — add 1 to a data index when a header slot is present.

ScrollToIndexOptions:

FieldTypeDefaultNotes
alignScrollAlign'top'Align the target cell to top, bottom, or middle.
offsetnumber0Extra pixel offset applied after alignment.
smoothbooleanfalseAnimate the scroll (default is a jump).

See Usage for worked examples of each feature.