0

I am making an application with chat (react-native-gifted-chat) and firebase-firestore and I am having a problem when showing them because when I send a message they repeat what they were already sending but it is only visual by data is ok How could it be solved?

1 Answers1

0
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
        }
    }
  }