-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RecaptchaClear doesn't actually work #8747
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Hi @White-waluigi, Some other users have encountered some nuances to using Recaptcha with React. Could you take a look at this StackOverflow thread and see if it solves your issue? Thanks. |
@DellaBitta I did see that Thread. But it didn't make sense to me because
|
Operating System
Manjaro
Environment (if applicable)
node 23.3, React
Firebase SDK Version
"firebase": "^11.1.0",
Firebase SDK Product(s)
Auth
Project Tooling
It is using react 18.3 with vite 6.0.01.
Detailed Problem Description
I am trying to build ReCaptchaButton component in React JS. For this to work I need to be able to create a RecaptchaVerfier as soon as the elment is mounted and destroy it as soon as it is unmounted. Unfortunately, the destroy part doesn't work. (In Strict Mode, React mounts a component, then immedietly unmounts it and then mounts a new instance, to enforce re-usability)
This wouldn't be a problem, but unfortunately, recaptchaVerifier.clear doesn't seem to actually do anything. Meaning, it stays attached to the dom (which react keeps as is) even as the component itself unmounts. The next mount then encounters an already captcha infested button and then throws an Error.
The only way I've been able to sort of make this work, is by anticipating the remount using a window.alreadyMounted variable and then reuse the verfier of the already unmounted component. This is an ugly hack which itself spits out a bunch of errors, namely:
and that is despite my efforts to suppress thrown errors. From what I've found, nobody has yet been able to integrated firebase embedded RecaptchaVerfier into a clean React component, simply because .clear doesn't actually clear the component.
Steps and code to reproduce issue
Here's the RecaptchaButton. Simply Mounting it once will spit out the Error:
reCAPTCHA has already been rendered in this element N recaptcha__en.js:477 Error
The text was updated successfully, but these errors were encountered: