FlatList is a more performant way to render large lists of items compared to ScrollView, as it only renders items that are currently visible on the screen.
Solution Code
React Native
-- Example Code --
import React from "react";
import { FlatList, Text, View } from "react-native";
const App = () => {
const data = [1, 2, 3, 4, 5];
return (
<FlatList
data={data}
renderItem={({ item }) => <Text>{item}</Text>}
keyExtractor={item => item.toString()}
/>
);
};
export default App;
Explanation
This code demonstrates how to use FlatList to render a list of items.Guided Hints
{'hint': 'FlatList is optimized for large lists.'}
{'hint': 'ScrollView renders all items at once.'}