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

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 :: create function in javascript 
Javascript :: setimout 
Javascript :: how to do if condition in kedo column in angular 
Javascript :: how to display words from an array in a box in javascript 
Javascript :: create table using jade 
Javascript :: javascript function with string parameter 
Javascript :: multi key cookie js 
Javascript :: get numbers from a string 
Javascript :: mongoose mongodb updateone 
Javascript :: react usestate 
Javascript :: what is closure in javascript 
Javascript :: how to do when enter is pressed javascript do smething 
Javascript :: remove equal json js 
Javascript :: check if alpine js is activated in website 
Javascript :: monaco editor no numbers 
Javascript :: pass ref to class component react 
Javascript :: interpolation in js 
Javascript :: react component key prop 
Javascript :: django pointfield json example 
Javascript :: angular 8 remove cookies 
Javascript :: vue router push with params 
Javascript :: javascript scroll to element with offset 
Javascript :: tinymce editor description value is not getting onclick js 
Javascript :: mongoose cursor eachasync 
Javascript :: regular expression email 
Javascript :: play audio file in phaser 
Javascript :: react testing library increase debug length 
Javascript :: How to get maximum value in Javascript 
Javascript :: how to disable eval in javascript 
Javascript :: vue date helper 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =