Migration to v3
Version 3 introduces first‑class Web support and a new SectionList component, plus several API improvements. It’s currently labeled beta while we collect feedback.
✨ New in v3
Web Support
- DOM‑native rendering (no React Native dependency required)
- Same virtualization core as React Native
- Web examples and docs
SectionList Component
@legendapp/list/section-listwith a React Native‑compatible APIscrollToLocationsupport- Sticky section headers powered by
stickyHeaderIndices
Always Render
alwaysRenderkeeps selected items mounted outside the virtualization window
Better Scroll & Metrics APIs
initialScrollAtEndfor chat and feedsonMetricsChangefor header/footer size changesgetState()now exposes listeners, element access, and scroll velocity
🔄 Breaking changes from v2
-
maintainVisibleContentPositiondefaults- v3 now enables scroll-position stabilization on size changes by default
- Default behavior is equivalent to
maintainVisibleContentPosition={{ size: true, data: false }} - Toggle specific behavior as needed:
maintainVisibleContentPosition={{ data: true }}to anchor on data changes toomaintainVisibleContentPosition={{ size: false }}to disable size/layout stabilizationmaintainVisibleContentPosition={true}to enable bothsizeanddatamaintainVisibleContentPosition={false}to disable both
-
Size callbacks argument order
getEstimatedItemSizeis now(item, index, type)getFixedItemSizeis now(item, index, type)
-
Sticky headers prop rename
stickyIndices→stickyHeaderIndices(deprecated alias kept for now)
-
Typed import paths
- Root import
@legendapp/listremains functional, but is deprecated for strict typing in v3. - Prefer:
- React Native:
@legendapp/list/react-native - React (Web):
@legendapp/list/react
- React Native:
- Root import
-
Keyboard integration entrypoint update
- v2 keyboard docs used
@legendapp/list/keyboard-controllerandLegendList. - In v3 use
@legendapp/list/keyboardand importKeyboardAvoidingLegendList. LegendListis no longer exported from the@legendapp/list/keyboardentrypoint.
- v2 keyboard docs used
-
Imperative scroll methods are async
- These ref methods now return
Promise<void>:scrollIndexIntoViewscrollItemIntoViewscrollToEndscrollToIndexscrollToItemscrollToOffset
- If you run logic after a programmatic scroll,
awaitthe call.
- These ref methods now return
-
getState()shape changed for advanced integrationsstate.positionsis no longer part of the publicgetState()return value.- Replace direct map access with:
positionAtIndex(index)positionByKey(key)
getState()now also exposes listener helpers (listen,listenToPosition) andscrollVelocity.
Migration checklist
- Update size callback signatures to
(item, index, type) - Replace
stickyIndiceswithstickyHeaderIndices - Move imports to typed platform entrypoints (
/react-nativeor/react) - Update keyboard imports from
@legendapp/list/keyboard-controllerto@legendapp/list/keyboardand useKeyboardAvoidingLegendList awaitimperative scroll calls if your code depends on post-scroll timing- Update advanced
getState()consumers to usepositionAtIndex/positionByKeyinstead ofpositions
Install
npm install @legendapp/list@beta