React Native & Expo (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is the difference between `ScrollView` and `FlatList`?
junior LevelCode Examplereact-nativeBasic
In Simple Words:
ScrollView: Renders every single child element in memory simultaneously upon mount! If you render 1,000 items, it creates 1,000 native views, instantly exhausting mobile RAM and freezing the app.FlatList: Virtualized list. Only renders the small window of items currently visible on screen. As the user scrolls, off-screen items are recycled, allowing smooth scrolling through tens of thousands of records with constant memory usage.
typescript
// Optimized FlatList Example:
<FlatList
data={orders}
keyExtractor={(item) => item.id}
renderItem={({ item }) => <OrderItem order={item} />}
initialNumToRender={10}
maxToRenderPerBatch={10}
windowSize={5}
/>