forked from appleboy/react-recaptcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
55 lines (47 loc) · 1.11 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import Recaptcha from '../src';
// site key
const sitekey = 'xxxxxxx';
// specifying your onload callback function
const callback = () => {
console.log('Done!!!!');
};
const verifyCallback = (response) => {
console.log(response);
};
const expiredCallback = () => {
console.log(`Recaptcha expired`);
};
// define a variable to store the recaptcha instance
let recaptchaInstance;
// handle reset
const resetRecaptcha = () => {
recaptchaInstance.reset();
};
class App extends React.Component {
render() {
return (
<div>
<h1>Google Recaptcha</h1>
<Recaptcha
ref={e => recaptchaInstance = e}
sitekey={sitekey}
size="compact"
render="explicit"
verifyCallback={verifyCallback}
onloadCallback={callback}
expiredCallback={expiredCallback}
/>
<br/>
<button
onClick={resetRecaptcha}
>
Reset
</button>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById('app'));