React-native Expo CLI,FlatList我正在尝试使用FlatList。但是它显示错误为-
- 错误:对象不能作为React的子对象(found: object with keys {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.......},{.....}]
这是由于错误的日期格式造成的
<Text>{PostInfo.From_Date} - 11/10/2021</Text>