简体   繁体   English

对象作为 React 子对象无效。 如果您打算渲染一组子项,请改用数组 - FlatList

[英]Objects are not valid as a React child. If you meant to render a collection of children, use an array instead - FlatList

React-native Expo CLI ,FlatList I'm trying use a FlatList. React-native Expo CLI ,FlatList 我正在尝试使用 FlatList。 but its showing me error as-但它向我显示错误为-

  • Error: Objects are not valid as a React child (found: object with keys {seconds, nanoseconds}).错误:对象作为 React 子对象无效(找到:带有键 {seconds, nanoseconds} 的对象)。 If you meant to render a collection of children, use an array instead.如果您打算渲染一组子项,请改用数组。

faltList code错误列表代码

{
 (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>
}

And Post Data is an array contains object received from firebase并且 Post Data 是一个包含从 firebase 接收到的对象的数组

PostData = [{name:"narendra",Age:5.......},{.....}]

这是由于错误的日期格式引起的

<Text>{PostInfo.From_Date} - 11/10/2021</Text>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对象作为 React 子级无效。 如果您打算渲染一组子项,请改用数组 - 错误 Solidity - React - Objects are not valid as a React child. If you meant to render a collection of children, use an array instead - Error Solidity - React “对象作为 React 子对象是无效的。 如果您打算渲染一组子项,请改用数组。” 错误 - “Objects are not valid as a React child. If you meant to render a collection of children, use an array instead.” error 如何修复错误:对象作为 React 子对象无效。 如果您打算渲染一组孩子,请改用数组 - How to fix error: Objects are not valid as a React child. If you meant to render a collection of children, use an array instead 错误:对象作为 React 子项无效。 如果您打算渲染一组孩子,请改用数组 - Error: Objects are not valid as a React child. If you meant to render a collection of children, use an array instead 对象作为 React 子项无效。 如果您打算呈现子集合,请改用数组 - Objects are not valid as a React child. If you meant to render a collection of children, use an array instead 对象作为 React 子项无效。 如果您打算渲染子集合,请改用数组。 如何退货? - Objects are not valid as a React child. If you meant to render a collection of children, use an array instead. How to return it? 未捕获的不变违规:对象无效作为React子代。 如果要渲染子级集合,请改用数组 - Uncaught Invariant Violation: Objects are not valid as a React child. If you meant to render a collection of children, use an array instead ReactJS 错误:对象作为 React 子项无效。 如果您打算渲染一组孩子,请改用数组 - ReactJS Error: Objects are not valid as a React child. If you meant to render a collection of children, use an array instead 错误:对象作为 React 子对象无效。 如果您打算渲染一组子项,请改用数组。 从 JSON 获取数据 - Error: Objects are not valid as a React child. If you meant to render a collection of children, use an array instead. Getting data from JSON 无法显示 ReactJS 中的数据。错误:对象作为 React 子项无效。 如果您打算呈现子集合,请改用数组 - Cannot display data in ReactJS. Error: Objects are not valid as a React child. If you meant to render a collection of children, use an array instead
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM