No matter what I pass as a second parameter it is undefined anyway.
How can i fix it
this is the function
export const createUserProfileDocument = async (userAuth, name) => {
if (!userAuth) return;
const userRef = firestore.doc(`users/${userAuth.uid}`);
const snapShot = await userRef.get();
if(!snapShot.exists) {
const { displayName, email } = userAuth;
const createdAt = new Date();
try {
await userRef.set({
displayName,
email,
createdAt,
name
})
} catch (error) {
console.log('error created a message', error.message);
}
}
return userRef;
};
this is how I call it
try {
const { user } = auth.createUserWithEmailAndPassword(email, password);
await createUserProfileDocument(user, displayName);
this.setState({
displayName: '',
email: '',
password: '',
confirmPassword: ''
});
} catch (error) {
console.error(error);
}
question from:
https://stackoverflow.com/questions/65892418/no-matter-what-i-pass-as-a-second-parameter-it-is-undefined-anyway 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…