0
0
React Nativemobile~5 mins

FlatList basics (data, renderItem, keyExtractor) in React Native - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the data prop in a FlatList?
The data prop provides the array of items that the FlatList will display. Each item in this array will be rendered as a list element.
Click to reveal answer
beginner
Explain the role of the renderItem prop in FlatList.
The renderItem prop is a function that tells FlatList how to display each item. It receives an object with the item data and returns a React element to render.
Click to reveal answer
beginner
Why do we use keyExtractor in FlatList?
The keyExtractor prop provides a unique key for each item in the list. This helps React Native track items efficiently and avoid rendering issues.
Click to reveal answer
intermediate
What happens if you don't provide a keyExtractor in FlatList?
If keyExtractor is missing, FlatList tries to use the item index as the key, which can cause problems when items are added, removed, or reordered, leading to UI glitches.
Click to reveal answer
intermediate
How does FlatList improve performance compared to ScrollView for long lists?
FlatList only renders items that are visible on the screen plus a small buffer, reducing memory use and improving performance. ScrollView renders all items at once, which can be slow for long lists.
Click to reveal answer
What type of data does the data prop in FlatList expect?
AA number
BA single object
CA string
DAn array of items
Which prop defines how each item in FlatList is displayed?
AkeyExtractor
Bdata
CrenderItem
Dstyle
What does the keyExtractor function return?
AA unique string key for each item
BThe item data itself
CThe index number as a number
DThe entire data array
If you omit keyExtractor, what key does FlatList use by default?
ANo key
BItem index
CItem name
DItem id
Why is FlatList preferred over ScrollView for long lists?
AFlatList renders only visible items, improving performance
BFlatList supports animations better
CScrollView does not support scrolling
DFlatList uses less memory for images
Describe how you would use data, renderItem, and keyExtractor together in a FlatList.
Think of data as your list of friends, renderItem as how you show each friend, and keyExtractor as giving each friend a name tag.
You got /3 concepts.
    Explain why providing a unique key with keyExtractor is important in FlatList.
    Imagine trying to find a friend in a crowd without name tags — it gets confusing!
    You got /3 concepts.