React | React Forms | Question 9

Last Updated :
Discuss
Comments

What will happen when the handleSubmit function is called in the following code?

JavaScript
const [email, setEmail] = useState("");
const [error, setError] = useState("");

const handleSubmit = () => {
    if (!validateEmail(email)) {
        setError("Invalid email");
    }
};

An error message "Invalid email" will be displayed when the email is invalid.

The email will be automatically corrected to a valid format.

The error state will be cleared on each submit.

The validateEmail function will be called without any effect.

Share your thoughts in the comments