I am trying to figure out how to set an image from the Firestore database for each user in react native gifted chat as the user's avatar, but I can not figure out how to do it.
I posted my code earlier on another question, but no one replied, so what is your approach for pulling a users image from Firebase Firestore and setting it as the avatar?
At the moment, to get the Users ID from Firestore, I have tried this, but it does not work.
async componentDidMount() {
this.setState({ user: firebaseApp.auth().currentUser });
this.listenForMessages(this.messagesRef);
const currentUserUID = firebaseApp.auth().currentUser.uid;
let doc = await firebaseApp
.firestore()
.collection('userProfile')
.doc(currentUserUID)
.get();
let dataObj = doc.data();
this.setState({ avatar: dataObj.image}); // CALLING IMAGE FROM DATABASE
}