prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 559 forks source link

createUser() error but still refreshes auth #1072

Open MorenoMdz opened 3 years ago

MorenoMdz commented 3 years ago

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

When you try to create a new user as in auth and it fails (duplicated email etc) the store state updates and no error is returned.

What is the expected behavior?

Screen to not refresh, as it is clearing the signup form.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

   "react-redux": "^7.2.1",
    "react-redux-firebase": "^3.10.0",
    "redux-firestore": "^0.13.0",

One of the ways I tried:

...
createUser = async (email, password, name, phone, address) => {
    await getFirebase().createUser(
      {
        email: email,
        password
      },
      {
        name,
        email: email,
        phone: phone,
        address: address,
        createdAt: new Date()
      }
    );
    this.setState({ loading: false });
  };
...

At the moment I am trying to set up it in a functional component, I might need to save the user input in a ref somehow to reuse it if the createUser() attempt still refreshes the screen/state.

Any idea why is it refreshing even on error? I tried catching the error in a try-catch it still reloads.

Thanks!

jonathan-chin commented 2 years ago

Hi, I'm experiencing this same issue. when it fails due to duplicate email (I haven't tested other kinds of failure), it updates the state, producing an infinite loop (for me). I've also tried using a try/catch block but to no avail.