Version 2
Version 2 is faster, more accurate, and smaller. There are no breaking changes, but itโs almost a full rewrite, so weโre calling it a major version!
This update is primarily focused on accuracy and performance. The maintainVisibleContentPosition algorithm was rewritten in a way thatโs much more accurate and performant, and also allowed us to remove a ton of hacks, workarounds, and lots of management code.
The new simpler implementation of maintainVisibleContentPosition enabled new features like sticky headers.
Many features were added to support advanced customization and behaviors for complex lists like AI chats.
Install the update
๐ Major Improvements
Accuracy
- Perfectly accurate
initialScrollIndex,scrollToIndex, andscrollToEnd - Bidirectional infinite scroll never has any flashing or jumpiness
- Uses average sizes after the first render so
estimatedItemSizeis now optional
Scroll Performance
maintainVisibleContentPositionis so much better and faster that itโs now enabled by default- Reduced number/size of renders while updating positions
- Improved container recycling to reuse containers more efficiently
โจ New Features
Sticky Headers
stickyIndicesprop for creating sticky headers that remain visible while scrolling
Enhanced Item Type System
getItemTypeprop allows categorizing different item types for better performance optimizationgetFixedItemSizeprop for items with known fixed sizes, enabling performance optimizationsrenderItem,getFixedItemSize, andgetEstimatedItemSizefunctions now receive an item type parameter
Lazy List
- Built-in lazy list support directly in the
LegendListcomponent
Scroll Position Management
snapToIndicesprop for snapping scroll position to specific item indicesmaintainVisibleContentPositionis now enabled by default for better scroll stability
Advanced Hooks and References
useSyncLayouthook for synchronizing layout operations- Ref function to enable/disable scroll processing for advanced use cases
getState()now includespositionAtIndexanddatafor debugging and advanced integrations
Code Quality
- Extracted most functionality into small, testable functions
- Added extensive test infrastructure
๐ Migration Guide
From v1 to v2
Most v2 changes are backward compatible, but note this one change:
maintainVisibleContentPositionnow defaults totrue. It has no significant overhead so it should be fine to leave it enabled. Itโs required for accurateinitialScrollIndex,scrollToIndex, and infinite scrolling up.