FlashList A high-performance list component with virtual scrolling support
A high-performance list component that supports virtual scrolling for handling large datasets efficiently while maintaining React Native-like APIs.
Virtual Scrolling : Only renders visible items for optimal performance
React Native-like API : Familiar interface similar to React Native's FlatList
Automatic Fallback : Falls back to standard rendering when virtual scrolling isn't needed
Flexible Sizing : Supports both fixed and variable item sizes
Scroll Events : Built-in support for scroll events and end-reached detection
import { FlashList } from "@/components/core/flash-list" ;
const data = [
{ id: "1" , title: "Item 1" },
{ id: "2" , title: "Item 2" },
// ... more items
];
function MyList () {
return (
< FlashList
data = {data}
renderItem = {({ item , index }) => (
< div className = "border-b p-4" >
< h3 >{item.title}</ h3 >
</ div >
)}
keyExtractor = {( item ) => item.id}
height = { 400 }
estimatedItemSize = { 60 }
/>
);
}
Prop Type Description dataT[]Array of items to render renderItem(info: { item: T; index: number }) => React.ReactNodeFunction to render each item keyExtractor(item: T, index: number) => stringFunction to extract unique keys
Prop Type Default Description itemSizenumber | ((index: number) => number)- Size of each item (enables virtual scrolling) estimatedItemSizenumber50Estimated size for virtual scrolling heightnumber | string400Height of the list container widthnumber | string"100%"Width of the list container overscannumber5Number of items to render outside the viewport
Prop Type Default Description onEndReached() => void- Called when user scrolls near the end onEndReachedThresholdnumber0.1Distance from end to trigger onEndReached (0-1) onScroll(e: React.UIEvent<HTMLDivElement>) => void- Scroll event handler horizontalbooleanfalseEnable horizontal scrolling
Prop Type Description ListHeaderComponentReact.ReactNode | (() => React.ReactNode)Component to render at the top ListFooterComponentReact.ReactNode | (() => React.ReactNode)Component to render at the bottom classNamestringCSS classes for the container contentContainerClassNamestringCSS classes for the content container
The FlashList automatically enables virtual scrolling when you provide an itemSize prop. This dramatically improves performance for large datasets by only rendering items that are currently visible.
< FlashList
data = {largeDataset}
renderItem = {renderItem}
itemSize = { 80 } // Fixed height of 80px per item
height = { 400 }
/>
< FlashList
data = {largeDataset}
renderItem = {renderItem}
itemSize = {( index ) => (index % 2 === 0 ? 60 : 100 )} // Variable heights
height = { 400 }
/>
Always provide keyExtractor for stable item identification
Use estimatedItemSize that's close to your actual item size
Set appropriate overscan values (higher = smoother scrolling, more DOM nodes)
Avoid complex calculations in renderItem - memoize if needed
function VirtualListExample () {
const data = Array. from ({ length: 10000 }, ( _ , i ) => ({
id: `item-${ i }` ,
title: `Item ${ i }` ,
}));
return (
< FlashList
data = {data}
renderItem = {({ item }) => (
< div className = "border-b p-4" >
< h3 >{item.title}</ h3 >
</ div >
)}
keyExtractor = {( item ) => item.id}
itemSize = { 60 }
height = { 400 }
onEndReached = {() => console. log ( "Reached end" )}
/>
);
}
function ListWithHeaderFooter () {
return (
< FlashList
data = {data}
renderItem = {renderItem}
ListHeaderComponent = {() => (
< div className = "bg-gray-100 p-4" >
< h2 >My List</ h2 >
</ div >
)}
ListFooterComponent = {() => (
< div className = "bg-gray-100 p-4" >
< p >End of list</ p >
</ div >
)}
itemSize = { 60 }
height = { 400 }
/>
);
}
function HorizontalList () {
return (
< FlashList
data = {data}
renderItem = {renderItem}
horizontal = { true }
itemSize = { 200 }
width = { 400 }
height = { 100 }
/>
);
}