appleboy / appleboy/react-recaptcha
.verifyCallback() does not work with es6 classes
- Dominant language
- JavaScript
- Stars
- 643
- Forks
- 96
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
When calling the `.execute()` method on the recaptcha instance, the `verifyCallback` function is not called if within an es6 class. The `verifyCallback` is only called when outside the class. This is not ideal as it doesn't allow you to submit a form.
**Doesn't work**
import * as React from 'react';
import { RouteComponentProps } from 'react-router';
var Recaptcha = require('react-recaptcha');
export class Submit extends React.Component, {}>{
recaptchaInstance: any;
constructor() {
super();
this.executeCaptcha = this.executeCaptcha.bind(this);
this.verifyCallback = this.verifyCallback.bind(this);
}
executeCaptcha() {
this.recaptchaInstance.execute();
}
verifyCallback(response){
console.log(response); // never is called
// submit form
}
render() {
return
Send
this.recaptchaInstance = e}
sitekey="xxxxxxxxxxxxxxxxxxxx"
size="invisible"
verifyCallback={this.verifyCallback}
/>
}
}
It _does_ work this way
import * as React from 'react';
import { RouteComponentProps } from 'react-router';
var Recaptcha = require('react-recaptcha');
const verifyCallback = function(response){
console.log(response);
// can't submit form now!? (or is there a way)
}
export class Submit extends React.Component, {}>{
recaptchaInstance: any;
constructor() {
super();
this.executeCaptcha = this.executeCaptcha.bind(this);
this.verifyCallback = this.verifyCallback.bind(this);
}
executeCaptcha() {
this.recaptchaInstance.execute();
}
verifyCallback(response){
console.log(response); // never is called
}
render() {
return
Send
this.recaptchaInstance = e}
sitekey="xxxxxxxxxxxxxxxxxxxx"
size="invisible"
verifyCallback={this.verifyCallback}
/>
}
}
Is there a way we can stick the `verifyCallback` in the class?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.