So I have a user registration form, where the user can sign up to the website.
Iām using React Moralis.
This is the function called upon submit of the registration form.
When I comment out signup()
it works fine
const { signup } = useMoralis();
const [email, setEmail] = useState("");
const [userName, setUserName] = useState("");
const [password, setPassword] = useState("");
const [rePassword, setRePassword] = useState("");
// Function called when the form is submitted.
const handleSubmit = (event) => {
//event.preventDefault() - for some reason this doesn't work either.
if (password === rePassword) {
signup(userName, password, email); // <-- The issue
} else {
console.log("Passwords do not match!");
}
};
The error I from signup() is
Ć
āā1 of 2 errors on the page
Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
I figured perhaps it is too many functions deep,
So I entered the signup directly into the form like so:
<form
name="contactForm"
id="contact_form"
className="form-border"
action=""
onSubmit={() => signup(userName, password, email)}
>
The page will load, however, The information I enter is not entered in the database.