Challenge - 5 Problems
FlatList Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What will this FlatList display?
Consider this React Native FlatList component. What text will appear on the screen?
React Native
import React from 'react'; import { FlatList, Text, View } from 'react-native'; const data = [{id: '1', name: 'Apple'}, {id: '2', name: 'Banana'}]; export default function App() { return ( <View> <FlatList data={data} keyExtractor={item => item.id} renderItem={({item}) => <Text>{item.name}</Text>} /> </View> ); }
Attempts:
2 left
💡 Hint
Look at what renderItem returns for each item.
✗ Incorrect
FlatList uses the data array and for each item calls renderItem, which returns a Text component showing item.name. So it displays 'Apple' and 'Banana'.
📝 Syntax
intermediate2:00remaining
Which keyExtractor is correct?
You want to use FlatList with this data: [{key: 'a'}, {key: 'b'}]. Which keyExtractor function will NOT cause a warning or error?
Attempts:
2 left
💡 Hint
The keyExtractor must return a string that exists in each item.
✗ Incorrect
Each item has a 'key' property, so keyExtractor should return item.key. Using item.id will be undefined and cause warnings.
❓ lifecycle
advanced2:00remaining
What happens if keyExtractor returns non-unique keys?
If FlatList's keyExtractor returns the same key for multiple items, what is the likely result?
Attempts:
2 left
💡 Hint
Keys must be unique to help React identify items.
✗ Incorrect
Non-unique keys cause React to confuse items, leading to warnings and rendering bugs.
🔧 Debug
advanced2:00remaining
Why does this FlatList show blank screen?
This FlatList code shows a blank screen. What is the problem?
const data = [{id: '1', title: 'One'}, {id: '2', title: 'Two'}];
item.id}
renderItem={() => {item.title} }
/>
Attempts:
2 left
💡 Hint
Check how renderItem receives its argument.
✗ Incorrect
renderItem must destructure or access the item from its argument. Here, renderItem has no parameter, so item is undefined.
🧠 Conceptual
expert2:00remaining
Why use keyExtractor instead of index as key?
Why is it better to use a unique id in keyExtractor instead of the item index as key in FlatList?
Attempts:
2 left
💡 Hint
Think about what happens when list items reorder.
✗ Incorrect
Keys help React track items. Using stable unique ids avoids bugs when items reorder or change. Index keys cause wrong item reuse.