convert all array object(firestore timestamp) to date

后端 未结 2 520
名媛妹妹
名媛妹妹 2021-01-26 15:29

I am using firestore and react-native-gifted-chat, I am trying to get all the chat messages from firestore to the chat. However, gifted chat does not support displaying firebase

相关标签:
2条回答
  • 2021-01-26 15:51

    Use renderTime prop of gifted chat and pass a function which converts the time and return that time in a string.

    0 讨论(0)
  • 2021-01-26 15:58

    Sorry for not explore deeply, after checking @Spatz comments I figure out how to do it

    documentData.forEach(a => {
      var date = a.createdAt.toDate()
      data.push({
        _id: a._id,
        createdAt: date,
        id: a.id,
        text: a.text,
        user: a.user
      })
    })
    
    0 讨论(0)
提交回复
热议问题