react-google-recaptcha
react-google-recaptcha copied to clipboard
Unable to reset after successful form submission
"react-google-recaptcha": "^2.0.1"
Method 1:
`const Contact = () => { const recaptchaRef = React.createRef();
const verifyCallback = () => { console.log( recaptchaRef.current.getValue() ) } return(
<ReCAPTCHA
sitekey="key"
onChange={verifyCallback}
theme="dark"
ref = {recaptchaRef}
/>
);
}`
Method 2:
`const Contact = () => { let recaptchaRef;
const verifyCallback = () => { console.log( recaptchaRef) } return(
<ReCAPTCHA
sitekey="key"
onChange={verifyCallback}
theme="dark"
ref = {e => recaptchaRef = e}
/>
);
}`
Both method gave null.
same issue
const recaptchaRef = useRef(null);
const handleSubmit = () => { ..... recaptchaRef.current.reset(); } ..... <ReCAPTCHA ref={recaptchaRef} sitekey={RECAPTCHA_KEY} onChange={onChange} />