CHAPTER 12
Beginner
Lists and ScrollView in React Native
Updated: May 16, 2026
5 min read
# CHAPTER 12
Lists and ScrollView in React Native
1. Introduction
By default, mobile screens do not scroll. If you render 20<Text> items inside a standard <View>, the items at the bottom will simply bleed off the edge of the physical screen and become entirely inaccessible. If you are building an Instagram feed or an e-commerce catalog, you need scrolling capabilities. In this chapter, we will master Lists and ScrollView. We will learn when to use the simple ScrollView wrapper for static pages, and when it is absolutely mandatory to use the highly-optimized FlatList component to render massive arrays of dynamic data without melting the phone's battery.
2. Learning Objectives
By the end of this chapter, you will be able to:-
Implement a basic
ScrollViewfor small, static content screens.
-
Understand the catastrophic memory issues of mapping large arrays inside a
ScrollView.
-
Implement a
FlatListfor massive, dynamic datasets.
-
Utilize the
data,renderItem, andkeyExtractorprops.
-
Build a structured
SectionListfor categorized data.
3. The ScrollView Component
ScrollView is the easiest way to make a screen scrollable. You simply replace your parent <View> with a <ScrollView>.
It is perfect for a "Terms of Service" text page, or a User Profile screen with a dozen static elements.
javascript
4. The ScrollView Memory Trap
If you have an array of 5,000 product objects, you might be tempted to use .map() inside a ScrollView to render 5,000 <ProductCard> components.
DO NOT DO THIS.
ScrollView renders *everything* inside it immediately. If you feed it 5,000 items, the React engine will try to calculate and draw 5,000 heavy UI components at the exact same millisecond. The app will freeze, RAM will spike to 100%, and the OS will crash the app.
5. The Solution: FlatList
For dynamic arrays, you MUST use FlatList.
FlatList is incredibly smart. It uses "Lazy Rendering." If you give it 5,000 items, it only draws the 10 items currently visible on the glass screen. As the user scrolls down, it destroys the top items and dynamically draws the new bottom items. The RAM usage stays perfectly flat at 10 items, no matter how large the array is!
6. Using FlatList (The 3 Core Props)
FlatList requires exactly three properties to function:
-
1.
data: The raw JavaScript array (the 5,000 objects).
-
2.
renderItem: A function that explains *how* to draw one single object from that array.
-
3.
keyExtractor: A function that tells React how to find the unique ID of each object.
javascript
7. SectionList (Categorized Data)
What if you want a list with sticky headers, like "A", "B", "C" in a Contacts app? UseSectionList! It expects the data array to be formatted with title and data properties.
javascript
8. Visual Learning: FlatList Lazy Rendering
txt
9. Common Mistakes
-
Forgetting Destructuring in
renderItem: TherenderItemfunction does NOT just pass the raw object. It passes a wrapper object containing layout data, indices, AND your item.
renderItem={(item) => <Text>{item.title}</Text>} (Crash: item.title is undefined).
GOOD: renderItem={({ item }) => <Text>{item.title}</Text>} (Notice the {} destructuring to pull the actual object out of the wrapper!).
10. Best Practices
-
Never nest Virtualized Lists: Never put a
FlatListdirectly inside aScrollView. They both contain complex scrolling math engines. They will fight each other, resulting in erratic scrolling behavior and console warnings.FlatListscrolls by itself automatically; it does not need a parentScrollView.
11. Practice Exercises
-
1.
What specific prop in a
FlatListtells React how to uniquely identify each row so it can efficiently update or delete items without redrawing the whole list?
-
2.
Write the syntax required to render an array of strings
['Apple', 'Banana']into aFlatList.
12. MCQs with Answers
Question 1
Why is it an architectural disaster to use a .map() function inside a <ScrollView> to render an array of 10,000 complex data objects?
Question 2
Which required property of the <FlatList> component is responsible for providing the actual visual JSX template (the UI) that dictates how a single object from the array should look on the screen?
13. Interview Questions
-
Q: Explain the mechanical difference between standard rendering in a
ScrollViewversus virtualized, lazy rendering in aFlatList.
-
Q: Describe the specific purpose of the
keyExtractorprop in aFlatList. How does React utilize these unique keys during the reconciliation phase when a list item is deleted?
-
Q: A developer has nested a vertical
FlatListdirectly inside a verticalScrollView. Explain why the React Native engine issues a severe warning against this pattern and what UI bugs it creates.
14. FAQs
Q: Can I pull down to refresh a FlatList like in Twitter? A: Yes!FlatList has built-in props exactly for this. Just add onRefresh={myRefreshFunction} and refreshing={isLoadingBool}. A native spinning wheel will automatically appear when the user pulls down from the top!
15. Summary
In Chapter 12, we mastered scrollable interfaces and infinite feeds. We utilized the basicScrollView wrapper to permit scrolling on small, static detail screens. More importantly, we averted catastrophic memory leaks by leveraging the highly-optimized FlatList component for dynamic data arrays. We mastered its triad of core properties—passing raw arrays to data, designing UI blueprints within renderItem, and enforcing strict memory mapping via keyExtractor.