Skip to content

Commit 72b1fb9

Browse files
authored
Merge pull request dozoisch#143 from dozoisch/2_0
2.0
2 parents f376dc3 + 14c9a6e commit 72b1fb9

File tree

6 files changed

+29
-21
lines changed

6 files changed

+29
-21
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- "10.0"
5-
- "8.0"
4+
- "12"
5+
- "10"
6+
- "8"
67

78
branches:
89
only:

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
v1.1.0 - Mon 12 Nov 2018 9:25 PST
1+
v2.0.0-rc.1 - Sat 3 Aug 2019 8:00 PST
2+
---------------------------------------
3+
4+
- Remove lang and removeOnUnmount global options [(#143)](https://github.com/dozoisch/react-google-recaptcha/issues/143)
5+
- Upgrade to node 8, 10, 12 [(#143)](https://github.com/dozoisch/react-google-recaptcha/issues/143)
6+
- Update to react-async-script 1.1 [(#143)](https://github.com/dozoisch/react-google-recaptcha/issues/143)
7+
8+
9+
v1.1.0 - Sun 14 Jul 2019 10:56 PST
210
---------------------------------------
311

412
- Add HL prop [(#141)](https://github.com/dozoisch/react-google-recaptcha/issues/141)

README.md

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

115115
#### Global properties used by reCaptcha
116116

117-
__lang__: 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-
119117
__useRecaptchaNet__: If google.com is blocked, you can set `useRecaptchaNet` to `true` so that the component uses recaptcha.net instead.
120118

121-
__removeOnUnmount__: If you plan to change the lang dynamically, `removeOnUnmount` should probably be `true`. This unloads the google recaptcha script on `componetWillUnmount` to allow for a new google recaptcha script to load next time the reCAPTCHA component is used to facilitate a new language if needed.
122119

123120
Example global properties:
124121
```js
125122
window.recaptchaOptions = {
126-
lang: 'fr',
127123
useRecaptchaNet: true,
128-
removeOnUnmount: false,
129124
};
130125
```
131126

@@ -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

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-google-recaptcha",
3-
"version": "1.1.0",
3+
"version": "2.0.0-rc.1",
44
"description": "React Component Wrapper for Google reCAPTCHA",
55
"main": "lib/index.js",
66
"module": "lib/esm/index.js",
@@ -53,6 +53,6 @@
5353
},
5454
"dependencies": {
5555
"prop-types": "^15.5.0",
56-
"react-async-script": "^1.0.0"
56+
"react-async-script": "^1.1.1"
5757
}
5858
}

src/recaptcha-wrapper.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import ReCAPTCHA from "./recaptcha";
22
import makeAsyncScriptLoader from "react-async-script";
33

4+
const callbackName = "onloadcallback";
5+
const globalName = "grecaptcha";
6+
47
function getOptions() {
58
return (typeof window !== "undefined" && window.recaptchaOptions) || {};
69
}
10+
711
function getURL() {
812
const dynamicOptions = getOptions();
9-
const lang = dynamicOptions.lang ? `&hl=${dynamicOptions.lang}` : "";
1013
const hostname = dynamicOptions.useRecaptchaNet ? "recaptcha.net" : "www.google.com";
11-
return `https://${hostname}/recaptcha/api.js?onload=${callbackName}&render=explicit${lang}`;
14+
return `https://${hostname}/recaptcha/api.js?onload=${callbackName}&render=explicit`;
1215
}
1316

14-
const callbackName = "onloadcallback";
15-
const globalName = "grecaptcha";
16-
const initialOptions = getOptions();
17-
1817
export default makeAsyncScriptLoader(getURL, {
1918
callbackName,
2019
globalName,
21-
removeOnUnmount: initialOptions.removeOnUnmount || false,
2220
})(ReCAPTCHA);

0 commit comments

Comments
 (0)