dozoisch / dozoisch/react-google-recaptcha

Cannot read properties of undefined (reading 'clients')

Open
#294 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.1k
Forks
148
PR merge metrics
No merged PRs in 30d

Description

react-google-recaptcha version: 3.1.0
react-async-script version: N/A

If I load the ReCaptcha, hit submit (taking me to the next page), then click browser back, I get the following error

`Cannot read properties of undefined (reading 'clients')`

I've tried the following;

1. grecaptcha.reset() the google recaptcha
2. I tried to reload the recaptcha from the window by calling `window.grecaptcha.reset()`
3. conditionally render the recaptcha based on a boolean
4. Tried reloading the recaptcha from its ref

```
const recaptchaRef = useRef(null);
const resetCaptcha = () => {
if (recaptchaRef.current) {
//@ts-ignore
recaptchaRef.current.reset();
}
};

{
setV2Succeeded(true)
resetCaptcha()
}}
onError={() => setV2Succeeded(false)}
onExpired={() => setV2Succeeded(false)}
/>

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the submit, next-page, and browser-back flow with react-google-recaptcha 3.1.0, then inspect the wrapper's mount, unmount, and script-loading behavior. Done means returning with the browser back button no longer produces the undefined `clients` error and reCAPTCHA remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.