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 :: js dynamic import js 
Javascript :: adding new sass version 
Javascript :: how to change the tab text in React 
Javascript :: vue.js cdn script 
Javascript :: how to master javascript 
Javascript :: how to generate random rgb color number in javascript 
Javascript :: javascript base64 encode file input 
Javascript :: how to copy to clipboard in react js 
Javascript :: mongoose find and update prop 
Javascript :: electron no menu bar 
Javascript :: js date format mm/dd/yyyy 
Javascript :: repeat string n times javascript 
Javascript :: convertir seconde 
Javascript :: dotenv nodejs 
Javascript :: javascript get hour from date 
Javascript :: excel datatable 
Javascript :: Toggle on button click in react js functional component 
Javascript :: usenavigate react router dom v6 
Javascript :: javascript transition 
Javascript :: free robux javascript 
Javascript :: discord js fetch user 
Javascript :: fetch api map 
Javascript :: prop type for ref in react js 
Javascript :: SAPUI5 formatter Date and Time 
Javascript :: javascript:void 
Javascript :: js foreach .childern 
Javascript :: regex match everything except 
Javascript :: add month date now javascript 
Javascript :: settimeout inside loop 
Javascript :: jquery toggle text on click 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =