So I'm using recaptcha script, however, I'm facing a issue with useReducer
I'm sharing the most relevant part of the code:
function onSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();
if (!recaptchaReady) return;
console.log("executed");
if (!recaptchaRendered) {
window.grecaptcha.render("recaptcha", {
sitekey: process.env.NEXT_PUBLIC_RECAPTCHA_SITEKEY,
callback: action === "signin" ? signin : signup,
size: "invisible",
});
setRecaptchaRendered(true);
} else {
window.grecaptcha.reset();
}
window.grecaptcha.execute();
}
Now, the functions signup/signup, uses a useReducer state. The state doesn't get updated for some reason, I need to rerender the recaptcha, which recaptcha doesn't allow. What can I do?