Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react native flatlist

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

const DATA = [
  {
    id: 'bd7acbea-c1b1-46c2-aed5-3ad53abb28ba',
    title: 'First Item',
  },
  {
    id: '3ac68afc-c605-48d3-a4f8-fbd91aa97f63',
    title: 'Second Item',
  },
  {
    id: '58694a0f-3da1-471f-bd96-145571e29d72',
    title: 'Third Item',
  },
];

const Item = ({ title }) => (
  <View style={styles.item}>
    <Text style={styles.title}>{title}</Text>
  </View>
);

const App = () => {
  const renderItem = ({ item }) => (
    <Item title={item.title} />
  );

  return (
    <SafeAreaView style={styles.container}>
      <FlatList
        data={DATA}
        renderItem={renderItem}
        keyExtractor={item => item.id}
      />
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: StatusBar.currentHeight || 0,
  },
  item: {
    backgroundColor: '#f9c2ff',
    padding: 20,
    marginVertical: 8,
    marginHorizontal: 16,
  },
  title: {
    fontSize: 32,
  },
});

export default App;
Comment

react native flatlist container style

<FlatList
    contentContainerStyle={{flexGrow: 1, justifyContent: 'center'}}
    //... other props
/>
Comment

PREVIOUS NEXT
Code Example
Javascript :: js replace 
Javascript :: sweetalert example 
Javascript :: javascript parsefloat 
Javascript :: react convert excel to json 
Javascript :: javascript array clear 
Javascript :: jquery post with promises 
Javascript :: remove duplicates in array 
Javascript :: import error in react 
Javascript :: js array random 
Javascript :: node schedule every minute 
Javascript :: google geocode nodejs 
Javascript :: how to toggle fa fa-caret-down and fa fa-caret-up using jquery 
Javascript :: assign input text value jquery 
Javascript :: local storage for chrome extension 
Javascript :: javascript filter array match includes exact 
Javascript :: angular chart js 
Javascript :: javascript ajouter une donnée à une list 
Javascript :: angular retry interceptor 
Javascript :: angular how to run code every time you route 
Javascript :: clear timeout in function js 
Javascript :: vue function data update 
Javascript :: create mongodb express server npm 
Javascript :: check the number is palindrome or not 
Javascript :: react-native restart app 
Javascript :: parsley validation checkbox 
Javascript :: variables in js 
Javascript :: run javascript sublime text 3 
Javascript :: js get copied text 
Javascript :: mangoosejs 
Javascript :: How do i write a script which generates a random rgb color number. 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =