Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
174 views
in Technique[技术] by (71.8m points)

reactjs - No matter what I pass as a second parameter it is undefined anyway

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...