Legend List 3.0 adds Web support and a SectionList component
updated
Legend List version 3 introduces first-class Web support and a new SectionList component, along with several API improvements. A migration guide covers the breaking changes from v2.
New in v3
Web support: DOM-native rendering that does not require a React Native dependency, using the same virtualization core as React Native, with web examples and docs.
SectionList: @legendapp/list/section-list offers a React Native-compatible API, scrollToLocation support and sticky section headers powered by stickyHeaderIndices.
Always render: alwaysRender keeps selected items mounted outside the virtualization window.
Scroll and metrics APIs:
initialScrollAtEndfor chat and feedsanchoredEndSpaceto reserve readable space after a chat or feed anchor rowcontentInsetEndAdjustmentfor floating composers and overlay UI at the end of a listuseKeyboardChatComposerInsetfor React Native keyboard chat composersonMetricsChangefor header/footer size changesgetState()now exposes listeners, element access and scroll velocity
Breaking changes from v2
- The root
@legendapp/listcomponent export has been removed. Use@legendapp/list/react-nativefor React Native and@legendapp/list/reactfor React (Web). - Scroll-position stabilization on size changes is now on by default, equivalent to
maintainVisibleContentPosition={{ size: true, data: false }}. Options such as{{ data: true }},{{ size: false }},trueandfalsetoggle the behavior. getFixedItemSizeis now(item, index, type).getEstimatedItemSizeandsuggestEstimatedItemSizehave been removed; the latter is replaced byref.current?.getState().getAverageItemSizes().stickyIndiceshas been removed in favor ofstickyHeaderIndices.- Keyboard integration moves from
@legendapp/list/keyboard-controllerto@legendapp/list/keyboard, which exportsKeyboardAwareLegendList,useKeyboardScrollToEndanduseKeyboardChatComposerInset.LegendListis no longer exported there.KeyboardAvoidingLegendListis available from@legendapp/list/keyboard-legacy. renderItemis called directly as a render callback. Hook-using item components should be returned from the callback, e.g.renderItem={({ item }) => <Row item={item} />}, rather than passed asrenderItem={Row}.scrollIndexIntoView,scrollItemIntoView,scrollToEnd,scrollToIndex,scrollToItemandscrollToOffsetnow returnPromise<void>.state.positionsis no longer part of the publicgetState()return value; usepositionAtIndex(index)andpositionByKey(key).getState()also exposeslisten,listenToPosition,scrollVelocityandgetAverageItemSizes().initialContainerPoolRatiohas been removed, as spare container capacity is managed automatically.InitialScrollAnchorhas been replaced byScrollIndexWithOffsetPosition.
The guide also includes a migration checklist summarizing these steps. The package installs with:
npm install @legendapp/list
Links
Source: legendapp.com