i'm trying to build a fake authentication react app with redux toolkits.
the problem is the button works only on second click.
the first click only checks the validation form, i had to click second one to pass to the action and change the redux state
this is my create account function:
const createAccount = (event) => {
const form = event.currentTarget;
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
setValidated(true);
const findUser = userList.find((user) => user.email === email);
// console.log(typeof findUser);
if (validated) {
if (findUser) {
alert("this user already exist, login?");
} else {
dispatch(signup(newAccount));
}
navigate("/signin", { replace: true });
}
};
Top comments (0)