You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-35Lines changed: 9 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,15 +17,13 @@ All you need to do is [sign up for an API key pair][signup]. You will need the c
17
17
You can then use the reCAPTCHA. The default require imports a wrapped component that loads the reCAPTCHA script asynchronously.
18
18
19
19
```jsx
20
-
var React =require("react").default;
21
-
var render =require("react-dom").render
22
-
var ReCAPTCHA =require("react-google-recaptcha");
20
+
importReCAPTCHAfrom"react-google-recaptcha";
23
21
24
22
functiononChange(value) {
25
23
console.log("Captcha value:", value);
26
24
}
27
25
28
-
render(
26
+
ReactDOM.render(
29
27
<ReCAPTCHA
30
28
ref="recaptcha"
31
29
sitekey="Your client site key"
@@ -68,7 +66,7 @@ window.recaptchaOptions = {
68
66
69
67
## Component API
70
68
71
-
The component also has some utility functions that can be called.
69
+
The component instance also has some utility functions that can be called. These can be accessed via `ref`.
72
70
73
71
-`getValue()` returns the value of the captcha field
74
72
-`getWidgetId()` returns the recaptcha widget Id
@@ -85,23 +83,16 @@ Starting with 0.7.0, the component now supports invisible options. See the [reCA
85
83
With the invisible option, you need to handle things a bit differently. You will need to call the `execute` method yourself.
86
84
87
85
```jsx
88
-
var React =require("react").default;
89
-
var render =require("react-dom").render
90
-
var ReCAPTCHA =require("react-google-recaptcha");
91
-
92
-
functiononChange(value) {
93
-
console.log("Captcha value:", value);
94
-
}
86
+
importReCAPTCHAfrom"react-google-recaptcha";
95
87
96
88
let captcha;
97
89
98
-
render(
90
+
ReactDOM.render(
99
91
<form onSubmit={() => { captcha.execute(); }}>
100
92
<ReCAPTCHA
101
93
ref={(el) => { captcha = el; }}
102
94
size="invisible"
103
95
sitekey="Your client site key"
104
-
onChange={onChange}
105
96
/>
106
97
</form>,
107
98
document.body
@@ -114,21 +105,14 @@ render(
114
105
You can also use the barebone components doing the following. Using that component will oblige you to manage the grecaptcha dep and load the script by yourself.
115
106
116
107
```jsx
117
-
var React =require("react").default;
118
-
var render =require("react-dom").render
119
-
var ReCAPTCHA =require("react-google-recaptcha/lib/recaptcha");
0 commit comments