Overview of Major Changes
No More Estimates
FlashList v2 automatically handles all sizing - no estimates required
Masonry as Prop
MasonryFlashList component is deprecated - use the
masonry prop insteadBetter Scroll Position
maintainVisibleContentPosition enabled by default for better handling
Modern API
Inverted prop deprecated - use maintainVisibleContentPosition instead
Migration Steps
Step 1: Update Package Version
Step 2: Remove Deprecated Props
Size Estimation Props (No Longer Needed)
Size Estimation Props (No Longer Needed)
The biggest change in v2 is that you no longer need to provide size estimates. FlashList v2 automatically handles all sizing.
Before
After
Other Deprecated Props
Other Deprecated Props
Remove these deprecated props from your FlashList components:Deprecated props:
inverted- UsemaintainVisibleContentPositioninstead (see Step 4)onBlankArea- No longer supporteddisableHorizontalListHeightMeasurement- No longer neededdisableAutoLayout- There’s no auto layout in v2
Step 3: Update Changed Props
overrideItemLayout - Size Estimates Removed
overrideItemLayout - Size Estimates Removed
In v1,
overrideItemLayout allowed both span changes and size estimates. In v2, it only supports span changes.v1 - Both span and size
v2 - Only span supported
Step 4: Replace Inverted Lists
Migrating from inverted prop
Migrating from inverted prop
If you were using the Key changes:
inverted prop (common in chat apps), replace it with maintainVisibleContentPosition and consider reversing your data array.v1 - Inverted list for chat
v2 - Use maintainVisibleContentPosition
The
maintainVisibleContentPosition feature is enabled by default in v2, but you can configure it for chat-like behavior with startRenderingFromBottom and autoscrollToBottomThreshold.- Replace
inverted={true}withmaintainVisibleContentPositionconfiguration - Use
onStartReachedinstead ofonEndReachedif loading older content from the top - Consider using
startRenderingFromBottom: truefor chat interfaces
Step 5: Migrate MasonryFlashList
From MasonryFlashList to FlashList with masonry prop
From MasonryFlashList to FlashList with masonry prop
The New feature: You can now use
MasonryFlashList component is deprecated. Use the masonry prop on FlashList instead.v1 - MasonryFlashList component
v2 - FlashList with masonry prop
optimizeItemArrangement prop to reduce differences in column height by modifying item order:Step 6: Update Ref Types
FlashListRef type change
FlashListRef type change
The ref type for FlashList has changed from The
FlashList to FlashListRef.v1
v2
FlashListRef type provides access to all list methods:scrollToIndex()scrollToItem()scrollToOffset()getVisibleIndices()getLayout()- And more…
Step 7: Replace CellContainer with View
CellContainer no longer exported
CellContainer no longer exported
CellContainer is no longer exported in v2. Replace it with React Native’s View.v1
v2
Apps forwarding custom
CellRendererComponent might need this change.Additional Considerations
Memoization is More Important
v1 was more selective about updating items, but this was often perceived as a bug by developers. v2 allows developers to ensure that props are memoized and will stop re-renders of children wherever it is obvious.keyExtractor is Highly Recommended
keyExtractor is important to prevent glitches due to item layout changes when going upwards. We highly recommend having a valid keyExtractor with v2.Remove Explicit key Props in renderItem
If you’re doing a.map() inside your items, use the useMappingHelper hook:
Check useState in renderItem
Check your
renderItem hierarchy for components that make use of useState and verify whether that state would need to be reset if a different item is passed to that component.useLayoutState- For state changes that affect layoutuseRecyclingState- For state that should reset when item changes
Performance Testing
FlashList can appear slower while in dev mode due to a small render buffer.Nesting Lists
If you’re nesting horizontal FlashLists in vertical lists, we highly recommend the vertical list to be FlashList too. We have optimizations to wait for child layout to complete which can improve load times.
Migration Checklist
- Update to
@shopify/flash-list@^2.0.0 - Remove size estimation props (
estimatedItemSize,estimatedListSize,estimatedFirstItemOffset) - Remove deprecated props (
inverted,onBlankArea,disableHorizontalListHeightMeasurement,disableAutoLayout) - Update
overrideItemLayoutto only usespan(removesize) - Replace
invertedwithmaintainVisibleContentPosition - Replace
MasonryFlashListwithFlashList+masonryprop - Update ref types from
FlashListtoFlashListRef - Replace
CellContainerwithView(if using custom cell renderer) - Remove explicit
keyprops inrenderItemhierarchy - Add
keyExtractorif not already present - Memoize props passed to FlashList
- Review
useStateusage in items - consider new hooks - Test performance in release mode
Next Steps
What's New in v2
Explore all the new features and improvements
Usage Guide
Learn about FlashList props and methods