FlatList is a high-performance component in React Native used to render large lists of data efficiently. It renders only visible items on the screen, improving memory usage and performance.
FlatList requires two main props: data and renderItem. Each item must have a unique key.
// Basic FlatList example in React Native
import React from 'react';
import { FlatList, Text, View } from 'react-native';
const data = [
{ id: '1', name: 'Apple' },
{ id: '2', name: 'Banana' },
{ id: '3', name: 'Mango' }
];
export default function App() {
return (
<View>
<FlatList
data={data}
keyExtractor={(item) => item.id}
renderItem={({ item }) => <Text>{item.name}</Text>}
/>
</View>
);
}
The list displays fruit names vertically. Only visible items are rendered, improving performance for large datasets.
This simulator demonstrates how a FlatList receives data and renders it into a scrollable view on a mobile screen. Add items below to update the simulated data array.
Scroll the phone screen to see the list behavior.
keyExtractor for unique keysinitialNumToRender for performance tuning