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
First of all [sign up for an API key pair][signup]. Then add the Google reCAPTCHA script tag to your html.
18
+
All you need to do is [sign up for an API key pair][signup]. You will need the client key.
19
19
20
-
The property set after `onload` is important and will be needed at render. This props is used to define a global callback, called by the Google script once it is loaded.
21
-
22
-
See the [Google reCAPTCHA docs][docs] for more info.
You can then use the reCAPTCHA. The default require, imports a wrapped component that loads the reCAPTCHA script asynchronously.
29
21
30
22
```jsx
31
23
var React =require("react");
@@ -37,9 +29,9 @@ function onChange(value) {
37
29
38
30
React.render(
39
31
<ReCATPCHA
40
-
sitekey="Your sitekey"
32
+
refs="recaptcha"
33
+
sitekey="Your client site key"
41
34
onChange={onChange}
42
-
onloadCallbackName="onloadcallback"
43
35
/>, document.body);
44
36
```
45
37
@@ -51,20 +43,45 @@ Other properties can be used to customised the rendering.
51
43
|:---- | ---- | ------ |
52
44
| sitekey | string | The API client key |
53
45
| onChange | func | The function to be called when the user completes successfully the captcha |
54
-
| onloadCallbackName | string | The name the script will call onload. **This must be the same provided on script tag.**
55
46
| theme | enum | *optional*`light` or `dark` The them of the widget *(__defaults:__ light)*
56
47
| type | enum | *optional*`image` or `audio` The type of initial captcha *(__defaults:__ image)*
57
48
| tabindex | number | *optional* The tabindex on the element *(__default:__ 0)*
58
-
| onLoad | func | *optional* callback called when the widget has rendered
59
49
| onExpired | func |*optional* callback when the challenge is expired and has to be redone by user. By default it will call the onChange with null to signify expired callback. |
60
50
61
51
## Component API
62
52
53
+
**To retrieve the component, when using the wrapper, do `this.refs.recaptcha.getComponent()`**
54
+
63
55
The component also has some utility functions that can be called.
64
56
65
57
-`getValue()` returns the value of the captcha field
66
58
-`reset()` forces reset. See the [JavaScript API doc][js_api]
67
59
60
+
### Advanced usage
61
+
62
+
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.
63
+
64
+
```jsx
65
+
var React =require("react");
66
+
var ReCATPCHA =require("react-google-recaptcha/lib/recaptcha");
67
+
68
+
var grecaptchaObject = grecaptcha // You must provide access to the google grecaptcha object.
0 commit comments