Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually send a request to recaptcha. #8

Open
AndreyPatseiko opened this issue May 29, 2019 · 2 comments
Open

Manually send a request to recaptcha. #8

AndreyPatseiko opened this issue May 29, 2019 · 2 comments

Comments

@AndreyPatseiko
Copy link

How can I delay my request for a recaptcha token?
I got response token after recaptcha was loading, for now. But I need execute recaptcha only when user fill my form.
How I can do this?

@lbudakov
Copy link

lbudakov commented Dec 24, 2019

You can achieve that the following way:

The below example code is not tested but the idea is the following

When the button is clicked the captcha is loaded and once the token is received the actual process that requires the captcha is started.

class Example extends Component {
  constructor(props) {
    super(props)
    this.state = {
      loadCaptcha: false
    }
  }

 handlePress = () => {
   this.setState({ loadCaptcha: true })
 }

handleReCaptchaExecute = (captcha) => {
  this.setState({ loadCaptcha: false });

  // Do whatever you want to do with the captcha
}

 render() {
   const { loadCaptcha } = this.state;
    const captchaComponent = (
      <View style={{ width: '100%', height: 0 }}>
        <ReCaptcha
          siteKey="SITEKEYHERE"
          url="URLHERE"
          action="verify"
          reCaptchaType={1} // invisible
          onExecute={this.handleReCaptchaExecute}
        />
      </View>
    );

    return (
      {loadCaptcha && captchaComponent}
      <Button
        title="Press me"
        color="#f194ff"
        onPress={this.handlePress}
      />
    )
  }

}

export default Example;

@amitmehtacode
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants