Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
createUserWithEmailAndPassword.then() not working

I was using Firebase to the register part of my project. Yesterday it was working fine, but now, the .then() of the createUserWithEmailAndPassword stop working and I don't understand why.

My code is very simple:

import React from "react";

import { auth } from "../../firebase";
import { createUserWithEmailAndPassword } from "firebase/auth";

class Register extends React.Component{

    onSubmit = (e) => {
        e.preventDefault();

        createUserWithEmailAndPassword(auth, "mail@mail.com", "password")
        .then((userCredential)=>{
            console.log(userCredential)
        })
    }

    render(){
                return(
                    <div className="add-form-container">
                        <h1 className="title">Registrarse</h1>
                        <span className="form-container">
                            <span className="input-add">
                                <p className="p-input">Usuario</p>
                                <input className="input-" id="input-user" type="text" />
                            </span>
                            <br />
                            <span className="input-add">
                                <p className="p-input">Correo electrónico</p>
                                <input className="input-" id="input-mail" type="email" />
                            </span>
                            <br />
                            <span className="input-add">
                                <p className="p-input">Contraseña</p>
                                <input className="input-" id="input-pass" type="password" />
                            </span>
                            <br />
                            <button className="add-button" onClick={this.onSubmit} id="post-button">Crear</button>
                        </span>
                    </div>
                );
            }
        }
    }
}

export default  Register;

Basically it return a console.log after create the user. The user is successfully created, but the console.log never shows. I changed it for alert() or another callback, but anything works.

Any solutions?

(I'm using only React and JavaScript)

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

My guess is that a user with the email address already exists, but to know for certain what's going wrong you should implement catch in addition to then:

createUserWithEmailAndPassword(auth, "mail@mail.com", "password")
.then((userCredential)=>{
    console.log(userCredential)
})
.catch((error) => {
    console.error(error);
});
about 4 years ago · Santiago Trujillo Report

0

Just in case my comment was actually the answer, I'll add it as an answer as well. Try adding a catch block to see if there are any errors when you try creating a new user:

createUserWithEmailAndPassword(auth, "mail@mail.com", "password")
  .then((userCredential)=>{
    console.log(userCredential)
  })
  .catch(err => console.log({err}))
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!