convert all array object(firestore timestamp) to date

后端 未结 2 414
轻奢々
轻奢々 2021-01-26 15:07

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:42

    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:44

    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)
提交回复
热议问题