khushboo29
khushboo29

Reputation: 916

Sample usage of gatsby-plugin-recaptcha

I have to use gatsby-plugin-recaptcha for forms in my project. I am not able to find any example of usage of this plugin. It will be big help if someone can share any information regarding this.

Thanks

Upvotes: 8

Views: 2553

Answers (2)

Kashi Mamidisetti
Kashi Mamidisetti

Reputation: 37

Place this code in your component and import <Helmet/> from react-helmet.

<React.Fragment>
  <Helmet>
    <script src={`https://www.google.com/recaptcha/api.js?r=${Math.random()}`} async defer>
    </script>
  </Helmet>
  <form>
    <div className="g-recaptcha" data-sitekey={REACAPTCHA_PUBLIC}>
    </div>
  </form>
</React.Fragment>

Upvotes: 2

Kashi Mamidisetti
Kashi Mamidisetti

Reputation: 37

` --> npm install --save reaptcha

import React, { Component } from 'react';
import Reaptcha from 'reaptcha';

class MyForm extends Component {
constructor(props) {
super(props);
this.state = {
  verified: false
 };
}

const onVerify = (recaptchaResponse) => {
this.setState({
  verified: true
});
};

render() { return ( Submit ); } }

 see the reference: https://github.com/sarneeh/reaptcha`

Upvotes: 0

Related Questions