【发布时间】:2021-12-05 15:34:22
【问题描述】:
React-native Expo CLI ,FlatList 我正在尝试使用 FlatList。但它向我显示错误-
- 错误: 对象作为 React 子对象无效(发现:对象带有键 {seconds, nanoseconds})。如果您打算渲染一组子项,请改用数组。
faltList 代码
{
(PostLoaded)?<FlatList
data = {PostData}
keyExtractor = {item => item.key}
renderItem={(itemData) => {
const PostInfo = itemData.item;
// console.log(PostInfo.Name);
return(
<View style={style.petshowContainer}>
<Image source={{uri:PostInfo.Image}}
style={{width:150,height:175,borderTopLeftRadius:10,borderBottomLeftRadius:10,}}
resizeMode='cover'
/>
<View style={{margin:10}}>
<Text style={{fontSize:25}}>{PostInfo.Name}</Text>
<View style={{flexDirection:'row',alignItems:'center'}}>
<Text style={{fontSize:15,marginRight:20}}>{PostInfo.Age}/ {PostInfo.Breed}</Text>
<Button mode='outlined' style={{borderColor:'blue'}}>{PostInfo.Gender}</Button>
</View>
<Text style={{marginBottom:5}}>Available for : </Text>
<Text>{PostInfo.From_Date} - 11/10/2021</Text>
<Button mode="contained" style={{marginTop:10}}>PetME</Button>
</View>
</View>
)
}}
style={{backgroundColor:'red'}}
/>:<Text>loading...</Text>
}
Post Data 是一个数组,包含从 firebase 接收的对象
PostData = [{name:"narendra",Age:5.......},{.....}]
【问题讨论】:
标签: javascript react-native expo react-native-flatlist