【问题标题】:fetching data from firestore. error: Invariant Violation: Objects are not valid as a React child从 Firestore 获取数据。错误:不变违规:对象作为 React 子对象无效
【发布时间】:2019-04-11 06:07:50
【问题描述】:

我正在从 Firestore 获取数据。当我 console.log 收到的结果时,一切看起来都很好,但是当我尝试显示它们时,我得到了这个错误:

未捕获的不变违规:对象作为 React 子级无效(发现:>带有键 {seconds, nanoseconds} 的对象)

console.log(props.transactions) 结果:

{props.transactions &&
   props.transactions
        .map(transaction => {
            return (
              <tr key={transaction.id}>
                 <td>{transaction.date}</td>
                 <td>{transaction.description}</td>
                 <td>{transaction.category}</td>
                 <Cell transactionType={transaction.transactionType}>
                   {transaction.amount}
                 </Cell>
                 <td>
                   <Button>Edit</Button>
                 </td>
               </tr>
              )
           })
}

【问题讨论】:

    标签: reactjs google-cloud-firestore components


    【解决方案1】:

    问题是您的transaction.date 之一是Timestamp 类型,它是一个对象,不能直接呈现。

    【讨论】:

      猜你喜欢
      • 2019-09-09
      • 2018-06-13
      • 2020-01-25
      • 2018-12-16
      • 2020-04-26
      • 1970-01-01
      • 1970-01-01
      • 2020-07-25
      • 1970-01-01
      相关资源
      最近更新 更多