The default Thank you message for my site was showing until I added the Recaptcha. Now I can receive the messages but the site just got reloaded and did not redirect to netlify thank you page after adding recaptcha.
The Site link.
https://eloquent-lamarr-932925.netlify.app/ (The form is at bottom, of home page, )
The Code
<Recaptcha
sitekey=“******************”
render=“explicit”
verifyCallback={verifyCallback}
onloadCallback={callback}
ref={e => recaptchaInstance = e}
/>
const handleSubmit = (e) => {
if (isVerified) {
fetch(“/”, {
method: “POST”,
headers: { “Content-Type”: “application/x-www-form-urlencoded” },
body: encode({
“form-name”: “home”,
…formState,
acceptsconsentcheckbox: acceptsConsentCheckbox,
}),
}).catch((error) => alert(error));
setFormState({
name: “”,
phone: “”,
email: “”,
message: “”,
});
} else {
alert(“Please verify that you are a human!”);
e.preventDefault();
}
};