What if you could build long, smooth lists with just a few lines of code?
Why FlatList basics (data, renderItem, keyExtractor) in React Native? - Purpose & Use Cases
Imagine you want to show a list of your favorite movies on your phone app. You try to add each movie one by one manually in your code, writing separate components for each movie.
This feels like writing a long list by hand every time you want to add or remove a movie.
Manually adding each item is slow and boring. If you want to change the list, you must rewrite many parts. It's easy to make mistakes like forgetting to update the order or missing an item.
Also, the app can become slow if you try to show many items this way because it tries to load everything at once.
FlatList helps by taking your list of data and automatically creating the list items for you. You just tell it what data to use, how to show each item, and how to identify each item uniquely.
This way, you write less code, avoid mistakes, and the app runs smoothly even with many items.
return ( <View> <Text>Movie 1: Inception</Text> <Text>Movie 2: Interstellar</Text> <Text>Movie 3: Dunkirk</Text> </View> );
return (
<FlatList
data={movies}
renderItem={({item}) => <Text>{item.title}</Text>}
keyExtractor={item => item.id.toString()}
/>
);FlatList makes it easy to build fast, scrollable lists that update automatically when your data changes.
Think about a contacts app that shows hundreds of friends. FlatList helps show all contacts smoothly and lets you add or remove friends without rewriting the whole list.
Manually coding lists is slow and error-prone.
FlatList automates list creation using your data and a render function.
It improves app performance and makes your code cleaner.