React Native – FlatList

FlatList is used for rendering a scrollable list of items efficiently. It supports data-driven rendering and offers built-in optimizations for large lists.

Use Cases:

  • Displaying lists of data such as contact lists, product lists, or chat messages.
  • Rendering long lists with optimized performance.

Example:

import React from 'react';
import { View, FlatList, Text, StyleSheet } from 'react-native';

const App = () => {
  const data = [
    { key: 'Car' },
    { key: 'Dan' },
    { key: 'Dominic' },
    { key: 'Cat' },
    { key: 'Alexa' },
    { key: 'Joel' },
    { key: 'John' },
    { key: 'Jillian' },
    { key: 'Apple' },
    { key: 'Julie' },
  ];

  return (
    <View style={styles.container}>
      <FlatList
        data={data}
        renderItem={({ item }) => <Text style={styles.item}>{item.key}</Text>}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingTop: 50,
  },
  item: {
    padding: 10,
    fontSize: 18,
    height: 44,
  },
});

export default App;

Tutorials Deck

TutorialsDeck is striving to provide the best learning material on technical and non-technical subjects.

Languages

Web Technologies

Database

Trending Technologies

© 2024. All rights reserved.

Contact Us @ tutorialsdeck06@gmail.com