Challenge - 5 Problems
FlatList Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate1:30remaining
FlatList keyExtractor usage
What is the main purpose of the
keyExtractor prop in a FlatList component?Attempts:
2 left
💡 Hint
Think about how React Native identifies each item in a list.
✗ Incorrect
The keyExtractor prop tells FlatList how to uniquely identify each item. This helps React Native optimize rendering by tracking items efficiently.
❓ lifecycle
intermediate1:30remaining
FlatList and extraData prop
Why should you use the
extraData prop in FlatList when your list depends on external state?Attempts:
2 left
💡 Hint
Think about how FlatList knows when to update its items.
✗ Incorrect
The extraData prop tells FlatList to watch for changes in external data and re-render the list accordingly.
🔧 Debug
advanced2:00remaining
FlatList performance issue with inline functions
What problem can arise if you pass an inline arrow function to the
renderItem prop of FlatList?React Native
renderItem={({ item }) => <Text>{item.name}</Text>}Attempts:
2 left
💡 Hint
Consider how React Native compares functions between renders.
✗ Incorrect
Passing inline functions creates a new function on every render, causing FlatList to think items changed and re-render them all.
🧠 Conceptual
advanced2:00remaining
Using getItemLayout for FlatList optimization
How does implementing the
getItemLayout prop improve FlatList performance?Attempts:
2 left
💡 Hint
Think about how FlatList calculates scroll positions.
✗ Incorrect
Providing getItemLayout lets FlatList know each item's size and position, so it can quickly scroll to items without measuring them dynamically.
expert
2:30remaining
FlatList and navigation performance
When navigating between screens with FlatList, what is a recommended way to preserve FlatList scroll position and avoid re-rendering all items?
Attempts:
2 left
💡 Hint
Think about how to keep UI state when switching screens.
✗ Incorrect
Using useFocusEffect allows you to save the scroll position when leaving and restore it when returning, preventing full re-renders and improving user experience.