Skip to content

Cannot read properties of undefined (reading 'clients') #294

@FreddieFruitSticks

Description

@FreddieFruitSticks

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();
    }
  };
  
  <ReCAPTCHA
        ref={recaptchaRef}
        hidden={!v3Failed}
        sitekey="..."
        onChange={() => {
          setV2Succeeded(true)
          resetCaptcha()
        }}
        onError={() => setV2Succeeded(false)}
        onExpired={() => setV2Succeeded(false)}
      />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions