0
0
React Nativemobile~20 mins

FlatList optimization techniques in React Native - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FlatList Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
1:30remaining
FlatList keyExtractor usage
What is the main purpose of the keyExtractor prop in a FlatList component?
ATo specify the style of each list item
BTo handle item press events
CTo define the number of items to render initially
DTo provide a unique key for each item to improve list rendering performance
Attempts:
2 left
💡 Hint
Think about how React Native identifies each item in a list.
lifecycle
intermediate
1:30remaining
FlatList and extraData prop
Why should you use the extraData prop in FlatList when your list depends on external state?
ATo set the maximum number of items to display
BTo force FlatList to re-render when the external state changes
CTo style the FlatList container
DTo disable scrolling
Attempts:
2 left
💡 Hint
Think about how FlatList knows when to update its items.
🔧 Debug
advanced
2: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>}
AIt disables item selection
BIt causes a syntax error
CIt causes FlatList to re-render all items unnecessarily, hurting performance
DIt prevents the list from scrolling
Attempts:
2 left
💡 Hint
Consider how React Native compares functions between renders.
🧠 Conceptual
advanced
2:00remaining
Using getItemLayout for FlatList optimization
How does implementing the getItemLayout prop improve FlatList performance?
AIt allows FlatList to skip measurement of item sizes and jump directly to any item
BIt changes the background color of list items
CIt disables lazy loading of items
DIt automatically sorts the list items
Attempts:
2 left
💡 Hint
Think about how FlatList calculates scroll positions.
navigation
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?
AUse React Navigation's <code>useFocusEffect</code> to save and restore scroll offset manually
BAlways unmount FlatList when leaving the screen
CDisable FlatList virtualization
DUse inline functions for renderItem to force re-render
Attempts:
2 left
💡 Hint
Think about how to keep UI state when switching screens.