I'm new to React Native and Firestore. I can't figure out why my document reference id keeps coming up as undefined in my console log, but there's an id in the Firestore database. I'm just trying to capture the id so that I can use it on another screen and add more fields to the document. Here is a sample of my code:
const handleSignUp = () => {
createUserWithEmailAndPassword(auth, email, password)
.then((userCredentials) => {
const user = userCredentials.user;
console.log("Registered with: ", user.email);
console.log("Welcome", name);
try {
const docRef = addDoc(collection(db, "userInfo"), {
fullname: name,
userID: uID,
});
console.log("Success writing document!", docRef.id, "yay");
} catch (e) {
console.error("Error adding document: ", e);
}
})
.catch((error) => alert(error.message));
};