I have a FlatList that renders a component called featured for each item in the list. I have several items in the list. However, the list isn't showing. Here's the code, and the flatlist has the renderItem called renderItem which returns the Featured component that we want to display:
import * as React from 'react';
import { FlatList, StyleSheet, TextInput, Image, Button, Pressable } from 'react-native';
//import { connect } from 'react-redux';
import EditScreenInfo from '../components/EditScreenInfo';
import { Text, View } from '../components/Themed';
import Featured from '../components/Featured';
//import getFeatured from "../"
export default function TabOneScreen(props) {
const renderItem = ({item}) => {
return (<Featured
artistName= {item.artistName}
mediaName= {item.mediaName}
uri={item.uri}
/>
);}
// useEffect(() => {
// getFeatured();
// })
return (
<View style={styles.container}>
<Text style={styles.title}>Discover Music to Own</Text>
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
<TextInput style={styles.searchbar}
placeholder="Search Music to Own"/>
<FlatList
data={props.featured}
renderItem={renderItem}
keyExtractor={item => item.mediaName}/>
</View>
)
}
const featured = [{uri:"https://i.guim.co.uk/img/media/68659a5732b6a11833ad642325c94276e73bfd17/1518_282_1533_920/master/1533.jpg?width=1200&height=900&quality=85&auto=format&fit=crop&s=55a7cd37c94dacf41f82d43e83352818",
artistName:"Beyonce",
mediaName:"Good Album Name",
videoUri:'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4'
},
{uri:"https://i.guim.co.uk/img/media/68659a5732b6a11833ad642325c94276e73bfd17/1518_282_1533_920/master/1533.jpg?width=1200&height=900&quality=85&auto=format&fit=crop&s=55a7cd37c94dacf41f82d43e83352818",
artistName:"Beyonce",
mediaName:"Good Album Name1",
videoUri:'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4'
},
{uri:"https://i.guim.co.uk/img/media/68659a5732b6a11833ad642325c94276e73bfd17/1518_282_1533_920/master/1533.jpg?width=1200&height=900&quality=85&auto=format&fit=crop&s=55a7cd37c94dacf41f82d43e83352818",
artistName:"Beyonce",
mediaName:"Good Album Name2",
videoUri:'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4'
}]
How to show the list?