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 flat list

import { FlatList } from 'react-native'

...

<FlatList
  data={items}
  renderItem={
    ({ item, index, separators }) => <Component item={item} />
  }
  keyExtractor={item => item.id}
/>
Comment

react native flatlist container style

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

flatlist inside flatlist react native

<FlatList
  data={data ? data : []}
  renderItem={({ outerItem }) => (
    <View>
      <FlatList
        data={outerItem["data"] ? outerItem["data"] : []}
        renderItem={({ innerItem }) => (
          <TouchableOpacity onPress={() => {
            navigation.navigate("Home", {
              artist_id: innerItem["artistID"]
            })
          }}>
            <View>
              <Text>Inner FlatList</Text>
            </View>
          </TouchableOpacity>
        )}
        keyExtractor={(innerItem) => innerItem.id}
      />
    </View>
  )}
/>
Comment

PREVIOUS NEXT
Code Example
Javascript :: mongoose unique field 
Javascript :: in select option how to make one default in angular 
Javascript :: ajax call do something while 
Javascript :: use thymeleaf variable in javascript 
Javascript :: check if string is datestring javascript 
Javascript :: timestamps in mongoose 
Javascript :: jwt token expire times 
Javascript :: f string javascript 
Javascript :: get ip of user in node js 
Javascript :: array int to string javascript 
Javascript :: update nodejs ubuntu 
Javascript :: how to make div visible and invisible in javascript 
Javascript :: how to pretty formatjson value on terminal ruby 
Javascript :: js int to alphabet 
Javascript :: shadown reAct native 
Javascript :: laravel query json 
Javascript :: move file from one folder to another in aws s3 nodejs 
Javascript :: new create react app 
Javascript :: check change event in jquery 
Javascript :: fetch patch method 
Javascript :: js get input from user 
Javascript :: react native submit on enter key 
Javascript :: react-native-reanimated npm 
Javascript :: react how to create range 
Javascript :: javascript delay 
Javascript :: remove border textinput react native 
Javascript :: jquery array 
Javascript :: open a particular slide on click button in owl carousel 
Javascript :: is_int js 
Javascript :: postman Assign variable to pre request script 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =