Skip to content
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

VM34 recaptcha__en.js:414 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'badge') #266

Open
igops opened this issue Mar 26, 2023 · 3 comments

Comments

@igops
Copy link

igops commented Mar 26, 2023

Preface: I'm using both reCAPTCHA V3 and V2 versions in the same app, is it legal? 🤔

I'm getting quite weird error while navigating between the pages. Explicit render gives me the same result.

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'badge')
    at VM34 recaptcha__en.js:414:153
    at r._renderRecaptcha (index.tsx:137:1)
    at index.tsx:216:1
    at new Promise (<anonymous>)
    at r.renderExplicitly (index.tsx:209:1)
    at p.<anonymous> (index.tsx:125:1)
    at callCallback (react-dom.development.js:13923:1)
    at commitUpdateQueue (react-dom.development.js:13944:1)
    at commitLayoutEffectOnFiber (react-dom.development.js:23364:1)
    at commitLayoutMountEffects_complete (react-dom.development.js:24688:1)

A workaround for me is to make React Router to reload the page, then error disappears.

That's how I render it so far: https://github.com/igops/tutorials/blob/main/njs-recaptcha-react/src/components/PhotoUnlockerRCv2.jsx#L41

P.S. I'm not an expert in React, so please don't be too harsh.

CleanShot 2023-03-27 at 01 36 17

@igops
Copy link
Author

igops commented Apr 2, 2023

After a small investigation I found out that loading reCAPTCHA V3 along with V2 breaks the latter.

A script loaded for V2: https://recaptcha.net/recaptcha/api.js?render=explicit
A script loaded for V3: https://www.google.com/recaptcha/api.js?render=xxxxxxxxxxxxxxxxx

When both loaded, V2 doesn't work anymore.

My tentative conclusion: do not use both version in the same app.

@jsardev
Copy link
Owner

jsardev commented Apr 2, 2023

Hey @igops! Sorry for a late reply and thank you for your investigation!

I think we could do something like a cleanup on unmounting the Reaptcha component which would allow to have a clean state on any other route, whatever version is used there. I will try to take a look at it this week, but not promising as I'm not a full-time open sourcerer 😅

@igops
Copy link
Author

igops commented Apr 2, 2023

@sarneeh hi Jacob, thank you for your response.

I'm not a front-end engineer, but I suspect this issue is probably out of scope of Reaptcha. Literally, Google scripts conflict with one another under the hood. To be honest, it's hard to imagine a real world case when both CAPTCHA versions are required in the same app (excepting the academic ones like mine 😄).

Nevertheless, I would appreciate any advise or contribution from your side! Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants