Skip to content

Commit 89df58c

Browse files
committed
Add upgrade guide and remove lang option completely
1 parent 6cb3448 commit 89df58c

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,8 @@ ReactDOM.render(
114114

115115
#### Global properties used by reCaptcha
116116

117-
__lang__: *DEPRECATED* By default google reCaptcha infers the user's interface language. In order to overwrite the language and update the translation for the reCaptcha widget, you can create a global variable configuring the desired language via `lang`.
118-
119-
*Instead use props.hl* reCaptcha now supports an hl property to be passed at render. The global lang parameter is no longer need and will be removed.
120-
121117
__useRecaptchaNet__: If google.com is blocked, you can set `useRecaptchaNet` to `true` so that the component uses recaptcha.net instead.
122118

123-
__removeOnUnmount__: *REMOVED* This was only useful for the lang changes. Lang is now changed through
124119

125120
Example global properties:
126121
```js
@@ -148,6 +143,12 @@ render(
148143
);
149144
```
150145

146+
## Migrate to 2.0
147+
148+
- __options.removeOnUnmount__: *REMOVED* This was only useful for the lang changes. Lang is now changed through the `hl` prop.
149+
- __options.lang__: *REMOVED* Instead pass it as the `hl` prop on the component.
150+
151+
151152
## Notes on Requirements
152153
At least `[email protected]` is required due to `forwardRef` usage in the dependency [react-async-script](https://github.com/dozoisch/react-async-script).
153154

src/recaptcha-wrapper.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import ReCAPTCHA, { getOptions } from "./recaptcha";
1+
import ReCAPTCHA from "./recaptcha";
22
import makeAsyncScriptLoader from "react-async-script";
33

44
const callbackName = "onloadcallback";
55
const globalName = "grecaptcha";
66

7+
function getOptions() {
8+
return (typeof window !== "undefined" && window.recaptchaOptions) || {};
9+
}
10+
711
function getURL() {
812
const dynamicOptions = getOptions();
913
const hostname = dynamicOptions.useRecaptchaNet ? "recaptcha.net" : "www.google.com";

src/recaptcha.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import React from "react";
22
import PropTypes from "prop-types";
33

4-
export function getOptions() {
5-
return (typeof window !== "undefined" && window.recaptchaOptions) || {};
6-
}
7-
84
export default class ReCAPTCHA extends React.Component {
95
constructor() {
106
super();
@@ -57,8 +53,6 @@ export default class ReCAPTCHA extends React.Component {
5753

5854
explicitRender() {
5955
if (this.props.grecaptcha && this.props.grecaptcha.render && this._widgetId === undefined) {
60-
const hl = this.props.hl || getOptions().lang || undefined;
61-
6256
const wrapper = document.createElement("div");
6357
this._widgetId = this.props.grecaptcha.render(wrapper, {
6458
sitekey: this.props.sitekey,
@@ -70,7 +64,7 @@ export default class ReCAPTCHA extends React.Component {
7064
"error-callback": this.handleErrored,
7165
size: this.props.size,
7266
stoken: this.props.stoken,
73-
hl,
67+
hl: this.props.hl,
7468
badge: this.props.badge,
7569
});
7670
this.captcha.appendChild(wrapper);

0 commit comments

Comments
 (0)