function createUser(email, password, username, dispatch) {
  firebaseApp
    .auth()
    .createUserWithEmailAndPassword(email, password)
    .then((response) => {
      storeTokenAndNavigate(response, dispatch);
      //save user name to the state
      dispatch({ type: "saveUsername", username: username });
      //call addUser to creat new user in db
      addUserToDB(username, dispatch);
    })
    .catch((error) => {
      dispatch({
        type: "add_error",
        payload: "Something went wrong with sign up. Reason:" + error.message,
      });
    });
}
//calls firebase sdk to sign up a user
calls firebase sdk to sign up a user
calls firebase sdk to sign up a user
function createUser(email, password, username, dispatch) {
  firebaseApp
    .auth()
    .createUserWithEmailAndPassword(email, password)
    .then((response) => {
      storeTokenAndNavigate(response, dispatch);
      dispatch({ type: "saveUsername", username: username });
      addUserToDB(username, dispatch);
    })
    .catch((error) => {
      dispatch({
        type: "add_error",
        payload: "Something went wrong with sign up. Reason:" + error.message,
      });
    });
}
function createUser ( email , password , username , dispatch ) { firebaseApp . auth ( ) . createUserWithEmailAndPassword ( email , password ) . then ( ( response ) => { storeTokenAndNavigate ( response , dispatch ) ; dispatch ( { type : "saveUsername" , username : username } ) ; addUserToDB ( username , dispatch ) ; } ) . catch ( ( error ) => { dispatch ( { type : "add_error" , payload : "Something went wrong with sign up. Reason:" + error . message , } ) ; } ) ; }
calls firebase sdk to sign up a user
calls firebase sdk to sign up a user
//save user name to the state //call addUser to creat new user in db