Skip to content

Legend List 2.0 focuses on accuracy and performance

updated

Version 2 of Legend List (@legendapp/list) is out. Its release page says it is faster, more accurate, and smaller. It introduces no breaking changes, but because it is nearly a full rewrite, the project is treating it as a major version.

The update centers on accuracy and performance. The maintainVisibleContentPosition algorithm was rewritten to be more accurate and performant, which also let the team remove many hacks, workarounds and management code. That simpler implementation made new features such as sticky headers possible. Several additions target advanced customization for complex lists like AI chats.

Improvements

Accuracy

  • Accurate initialScrollIndex, scrollToIndex, and scrollToEnd
  • Bidirectional infinite scroll without flashing or jumpiness
  • Average sizes are used after the first render, so estimatedItemSize is now optional

Scroll performance

  • maintainVisibleContentPosition is now enabled by default
  • Fewer and smaller renders while updating positions
  • More efficient container recycling

New features

  • Sticky headers: a stickyIndices prop keeps headers visible while scrolling
  • Item types: getItemType categorizes items for performance optimization, and getFixedItemSize handles items with known fixed sizes. renderItem, getFixedItemSize, and getEstimatedItemSize now receive an item type parameter
  • Lazy list: built-in lazy list support directly in the LegendList component
  • Scroll position: a snapToIndices prop snaps scrolling to specific item indices
  • Hooks and refs: a useSyncLayout hook for synchronizing layout operations, a ref function to enable or disable scroll processing, and getState() now includes positionAtIndex and data
  • Code quality: most functionality was extracted into small, testable functions, and extensive test infrastructure was added

Migration

Most changes are backward compatible. The one change to note is that maintainVisibleContentPosition now defaults to true. The project says it has no significant overhead and is required for accurate initialScrollIndex, scrollToIndex, and infinite scrolling up.

Source: legendapp.com