dozoisch / dozoisch/react-google-recaptcha
Help needed on find when invisible captcha is ready to use.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 148
- PR merge metrics
- No merged PRs in 30d
Description
react-google-recaptcha version: 1.0.5
Hi @dozoisch,
I want to know if there is any way to find when the recaptcha is ready to use.
I'm using Invisible type recaptcha and I have a button that I want to enable only when invisible recaptcha is completely loaded and ready to use. I could not find any event or callback fired to determine when recaptcha is completely ready to use. Please let me know if anyone use a proper way to handle this usecase.
Attached my sample component here:
`
class MyComp extends PureComponent {
constructor(props) {
super(props);
this.submit = this.submit.bind(this);
this.onSubmitHandler = this.onSubmitHandler.bind(this);
this.onCaptchaLoaded = this.onCaptchaLoaded.bind(this);
this.recaptchaRef = React.createRef();
}
onSubmitHandler(e) {
e.preventDefault();
if (!!this.recaptchaRef.current.getValue()) {
this.submit();
} else {
this.recaptchaRef.current.execute();
}
}
submit() {
//actual submit action logic goes here
}
onCaptchaLoaded() {
this.setState({ captchaLoaded: true });
}
render() {
return (
{
if (response) {
this.submit();
} else {
this.recaptchaRef.current.execute();
}
}}
asyncScriptOnLoad= {this.onCaptchaLoaded}
/>
button text
);
}
}`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.