Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
How to call more functions on completing user signup?

I am creating a login function with react and firebase, i want to call two more functions on completing signup, I tried doing

  const signUpSubmit = (e,closeSignUpCard,openSignInCard) => {
      e.preventDefault();
      const email = e.target.email.value;
      const password = e.target.password.value;

      signInWithEmailAndPassword(auth, email, password)
        .then(() => {
        closeSignUpCard();
        openSignInCard();
    }
    .catch((error) => {
          alert(error.message);
    });
};

but it shows error:

closeSignUpCard is not defined
openSignInCard is not defined

is there any other way to go about doing this? btw, i'm using firebase:^9.1.0

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could turn your signUpSubmit function into an async funcion, and just await for the internal promises to end. This way you don't need to get into a callback hell and still things will happen after events you have some kind of control.

Also, if the openSignInCard function must be executed after the closeSignUpCard function, you can turn them into async functions and use await before they are called, so the next one will only be called after the first one ends.

Remember to be careful of using too much awaits. You know, users don't like waiting too much

const signUpSubmit = async (e, closeSignUpCard, openSignInCard) {
   e.preventDefault()
   const email = e.target.email.value
   const password = e.target.password.value

   const signIn = await signInWithEmailAndPassword(auth, email, password)
      .then(r => { return { success: true } })
      .catch(e => { return { success: false, error: e.message })

   if ( signIn.success ){
      closeSignUpCard()
      openSignInCard()
   } else {
      alert(signIn.error)
   }
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda