What is FlatList?
- displays a scrolling list of changing, but similarly structured, data.
Unlike the more generic ScrollView, the FlatList only renders elements that are currently
showing on the screen, not all the elements at once(unlike ScrollView).
Designed to efficiently render large lists of data with optimal performance. FlatList component requires two props: data and renderItem
Very Good Video
Examples
Simple FlatList
|
1. import 2. Create Array of Object in JavaScript. [] is Array, {} is Object Array/list/collection [] is collection of values, Can contain multiple elements of different types Object/HashMap/Dictionary {}: key-value pair collection Nested Objects in Arrays. Placing {} inside [] creates an array of objects This format will remain consistent across React Native FlatList implementations: 3. Define FlatList inside SafeAreaView
4. keyExtractor is function, which returns which property on object is used as keykeyExtractor{(item) => } //item is fixed always Make students.id as key
5. renderItem Arrow Function
|