【问题标题】:(react-native-gifted-chat with firebase-firestore) more messages are displayed when sending one(react-native-gifted-chat with firebase-firestore) 发送一条消息时会显示更多消息
【发布时间】:2019-09-13 19:16:16
【问题描述】:

我正在使用聊天 (react-native-gifted-chat) 和 firebase-firestore 制作应用程序,但在显示它们时遇到问题,因为当我发送消息时,它们会重复他们已经发送的内容,但这只是视觉效果按数据还可以 怎么解决?

【问题讨论】:

    标签: react-native react-native-gifted-chat


    【解决方案1】:
    if(doc._id === this.state.user.uid){
        messages = { 
            _id: Math.round(Math.random() * 1000000), // () => hacia quien se envia
            createdAt: new Date(doc.createdAt.seconds * 1000),
            text: doc.text,
            user: {
                _id: this.state.uid2, // quien lo envia => ()
                name: this.state.chat
            }
        }
      } else {
        messages = { 
            _id: Math.round(Math.random() * 1000000),
            createdAt: new Date(doc.createdAt.seconds * 1000),
            text: doc.text,
            user: {
                _id: this.state.user.uid,
                name: this.state.user.displayName
            }
        }
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-30
      • 1970-01-01
      相关资源
      最近更新 更多