@hcaptcha/react-hcaptcha 1.11.1 → 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/esm/index.js +21 -23
- package/dist/index.js +21 -23
- package/package.json +1 -1
- package/src/index.js +17 -14
package/README.md
CHANGED
|
@@ -192,9 +192,16 @@ Please note that "invisible" simply means that no hCaptcha button will be render
|
|
|
192
192
|
3. #### Make sure you are using `reCaptchaCompat=false` if you have the reCAPTCHA JS loaded on the same page.
|
|
193
193
|
The hCaptcha "compatibility mode" will interfere with reCAPTCHA, as it adds properties with the same name. If for any reason you are running both hCaptcha and reCAPTCHA in parallel (we recommend only running hCaptcha) then please disable our compatibility mode.
|
|
194
194
|
|
|
195
|
-
4. #### Avoid conflicts with legacy Sentry package usage on react-hcaptcha 1.9.0+
|
|
196
|
-
If you are using Sentry 7.x in your React app, this can conflict with the upstream `hcaptcha-loader` package's Sentry error tracing. You can avoid this issue by setting the `sentry` prop to `false`.
|
|
197
195
|
|
|
196
|
+
### Sentry
|
|
197
|
+
|
|
198
|
+
If the `sentry` flag is enabled, the upstream `hcaptcha-loader` package expects the Sentry SDK, version 8.x or later.
|
|
199
|
+
|
|
200
|
+
If you have an older `@sentry/browser` client version on your site, it may take precedence over the bundled version. In this case you may see a console error like "g.setPropagationContext is not a function" due to the hcaptcha-loader trying to call methods only available on newer Sentry clients.
|
|
201
|
+
|
|
202
|
+
To resolve this, update the version of the Sentry client you are including on your site to 8.x or higher.
|
|
203
|
+
|
|
204
|
+
You can avoid this issue by setting the `sentry` prop to `false`.
|
|
198
205
|
|
|
199
206
|
|
|
200
207
|
---
|
package/dist/esm/index.js
CHANGED
|
@@ -37,11 +37,11 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
37
37
|
_this.ref = /*#__PURE__*/React.createRef();
|
|
38
38
|
_this.apiScriptRequested = false;
|
|
39
39
|
_this.sentryHub = null;
|
|
40
|
+
_this.captchaId = '';
|
|
40
41
|
_this.state = {
|
|
41
42
|
isApiReady: false,
|
|
42
43
|
isRemoved: false,
|
|
43
|
-
elementId: props.id
|
|
44
|
-
captchaId: ''
|
|
44
|
+
elementId: props.id
|
|
45
45
|
};
|
|
46
46
|
return _this;
|
|
47
47
|
}
|
|
@@ -75,8 +75,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
75
75
|
this.loadCaptcha();
|
|
76
76
|
};
|
|
77
77
|
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
78
|
-
var captchaId = this.state.captchaId;
|
|
79
78
|
var hcaptcha = this._hcaptcha;
|
|
79
|
+
var captchaId = this.captchaId;
|
|
80
80
|
if (!this.isReady()) {
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
@@ -156,10 +156,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
156
156
|
};
|
|
157
157
|
_proto.renderCaptcha = function renderCaptcha(onRender) {
|
|
158
158
|
var _this4 = this;
|
|
159
|
-
var _this$state = this.state,
|
|
160
|
-
isApiReady = _this$state.isApiReady,
|
|
161
|
-
captchaId = _this$state.captchaId;
|
|
162
159
|
var onReady = this.props.onReady;
|
|
160
|
+
var isApiReady = this.state.isApiReady;
|
|
161
|
+
var captchaId = this.captchaId;
|
|
163
162
|
|
|
164
163
|
// Prevent calling hCaptcha render on two conditions:
|
|
165
164
|
// • API is not ready
|
|
@@ -179,9 +178,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
179
178
|
var hcaptcha = this._hcaptcha;
|
|
180
179
|
//Render hCaptcha widget and provide necessary callbacks - hCaptcha
|
|
181
180
|
var id = hcaptcha.render(this.ref.current, renderParams);
|
|
181
|
+
this.captchaId = id;
|
|
182
182
|
this.setState({
|
|
183
|
-
isRemoved: false
|
|
184
|
-
captchaId: id
|
|
183
|
+
isRemoved: false
|
|
185
184
|
}, function () {
|
|
186
185
|
onRender && onRender();
|
|
187
186
|
onReady && onReady();
|
|
@@ -189,8 +188,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
189
188
|
});
|
|
190
189
|
};
|
|
191
190
|
_proto.resetCaptcha = function resetCaptcha() {
|
|
192
|
-
var captchaId = this.state.captchaId;
|
|
193
191
|
var hcaptcha = this._hcaptcha;
|
|
192
|
+
var captchaId = this.captchaId;
|
|
194
193
|
if (!this.isReady()) {
|
|
195
194
|
return;
|
|
196
195
|
}
|
|
@@ -202,8 +201,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
202
201
|
});
|
|
203
202
|
};
|
|
204
203
|
_proto.removeCaptcha = function removeCaptcha(callback) {
|
|
205
|
-
var captchaId = this.state.captchaId;
|
|
206
204
|
var hcaptcha = this._hcaptcha;
|
|
205
|
+
var captchaId = this.captchaId;
|
|
207
206
|
if (!this.isReady()) {
|
|
208
207
|
return;
|
|
209
208
|
}
|
|
@@ -242,10 +241,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
242
241
|
};
|
|
243
242
|
_proto.handleSubmit = function handleSubmit(event) {
|
|
244
243
|
var onVerify = this.props.onVerify;
|
|
245
|
-
var
|
|
246
|
-
isRemoved = _this$state2.isRemoved,
|
|
247
|
-
captchaId = _this$state2.captchaId;
|
|
244
|
+
var isRemoved = this.state.isRemoved;
|
|
248
245
|
var hcaptcha = this._hcaptcha;
|
|
246
|
+
var captchaId = this.captchaId;
|
|
249
247
|
if (typeof hcaptcha === 'undefined' || isRemoved) return;
|
|
250
248
|
var token = hcaptcha.getResponse(captchaId); //Get response token from hCaptcha widget
|
|
251
249
|
var ekey = hcaptcha.getRespKey(captchaId); //Get current challenge session id from hCaptcha widget
|
|
@@ -253,8 +251,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
253
251
|
};
|
|
254
252
|
_proto.handleExpire = function handleExpire() {
|
|
255
253
|
var onExpire = this.props.onExpire;
|
|
256
|
-
var captchaId = this.state.captchaId;
|
|
257
254
|
var hcaptcha = this._hcaptcha;
|
|
255
|
+
var captchaId = this.captchaId;
|
|
258
256
|
if (!this.isReady()) {
|
|
259
257
|
return;
|
|
260
258
|
}
|
|
@@ -268,8 +266,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
268
266
|
};
|
|
269
267
|
_proto.handleError = function handleError(event) {
|
|
270
268
|
var onError = this.props.onError;
|
|
271
|
-
var captchaId = this.state.captchaId;
|
|
272
269
|
var hcaptcha = this._hcaptcha;
|
|
270
|
+
var captchaId = this.captchaId;
|
|
273
271
|
if (this.isReady()) {
|
|
274
272
|
// If hCaptcha runs into error, reset captcha - hCaptcha
|
|
275
273
|
hcaptcha.reset(captchaId);
|
|
@@ -277,9 +275,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
277
275
|
if (onError) onError(event);
|
|
278
276
|
};
|
|
279
277
|
_proto.isReady = function isReady() {
|
|
280
|
-
var _this$
|
|
281
|
-
isApiReady = _this$
|
|
282
|
-
isRemoved = _this$
|
|
278
|
+
var _this$state = this.state,
|
|
279
|
+
isApiReady = _this$state.isApiReady,
|
|
280
|
+
isRemoved = _this$state.isRemoved;
|
|
283
281
|
return isApiReady && !isRemoved;
|
|
284
282
|
};
|
|
285
283
|
_proto.handleOpen = function handleOpen() {
|
|
@@ -307,8 +305,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
307
305
|
}
|
|
308
306
|
opts = typeof opts === 'object' ? opts : null;
|
|
309
307
|
try {
|
|
310
|
-
var captchaId = this.state.captchaId;
|
|
311
308
|
var hcaptcha = this._hcaptcha;
|
|
309
|
+
var captchaId = this.captchaId;
|
|
312
310
|
if (!this.isReady()) {
|
|
313
311
|
var _opts;
|
|
314
312
|
var onReady = new Promise(function (resolve, reject) {
|
|
@@ -337,16 +335,16 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
337
335
|
}
|
|
338
336
|
};
|
|
339
337
|
_proto.close = function close() {
|
|
340
|
-
var captchaId = this.state.captchaId;
|
|
341
338
|
var hcaptcha = this._hcaptcha;
|
|
339
|
+
var captchaId = this.captchaId;
|
|
342
340
|
if (!this.isReady()) {
|
|
343
341
|
return;
|
|
344
342
|
}
|
|
345
343
|
return hcaptcha.close(captchaId);
|
|
346
344
|
};
|
|
347
345
|
_proto.setData = function setData(data) {
|
|
348
|
-
var captchaId = this.state.captchaId;
|
|
349
346
|
var hcaptcha = this._hcaptcha;
|
|
347
|
+
var captchaId = this.captchaId;
|
|
350
348
|
if (!this.isReady()) {
|
|
351
349
|
return;
|
|
352
350
|
}
|
|
@@ -357,11 +355,11 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
357
355
|
};
|
|
358
356
|
_proto.getResponse = function getResponse() {
|
|
359
357
|
var hcaptcha = this._hcaptcha;
|
|
360
|
-
return hcaptcha.getResponse(this.
|
|
358
|
+
return hcaptcha.getResponse(this.captchaId);
|
|
361
359
|
};
|
|
362
360
|
_proto.getRespKey = function getRespKey() {
|
|
363
361
|
var hcaptcha = this._hcaptcha;
|
|
364
|
-
return hcaptcha.getRespKey(this.
|
|
362
|
+
return hcaptcha.getRespKey(this.captchaId);
|
|
365
363
|
};
|
|
366
364
|
_proto.render = function render() {
|
|
367
365
|
var elementId = this.state.elementId;
|
package/dist/index.js
CHANGED
|
@@ -55,11 +55,11 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
55
55
|
_this.ref = /*#__PURE__*/React.createRef();
|
|
56
56
|
_this.apiScriptRequested = false;
|
|
57
57
|
_this.sentryHub = null;
|
|
58
|
+
_this.captchaId = '';
|
|
58
59
|
_this.state = {
|
|
59
60
|
isApiReady: false,
|
|
60
61
|
isRemoved: false,
|
|
61
|
-
elementId: props.id
|
|
62
|
-
captchaId: ''
|
|
62
|
+
elementId: props.id
|
|
63
63
|
};
|
|
64
64
|
return _this;
|
|
65
65
|
}
|
|
@@ -96,8 +96,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
96
96
|
}, {
|
|
97
97
|
key: "componentWillUnmount",
|
|
98
98
|
value: function componentWillUnmount() {
|
|
99
|
-
var captchaId = this.state.captchaId;
|
|
100
99
|
var hcaptcha = this._hcaptcha;
|
|
100
|
+
var captchaId = this.captchaId;
|
|
101
101
|
if (!this.isReady()) {
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
@@ -185,10 +185,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
185
185
|
key: "renderCaptcha",
|
|
186
186
|
value: function renderCaptcha(onRender) {
|
|
187
187
|
var _this4 = this;
|
|
188
|
-
var _this$state = this.state,
|
|
189
|
-
isApiReady = _this$state.isApiReady,
|
|
190
|
-
captchaId = _this$state.captchaId;
|
|
191
188
|
var onReady = this.props.onReady;
|
|
189
|
+
var isApiReady = this.state.isApiReady;
|
|
190
|
+
var captchaId = this.captchaId;
|
|
192
191
|
|
|
193
192
|
// Prevent calling hCaptcha render on two conditions:
|
|
194
193
|
// • API is not ready
|
|
@@ -208,9 +207,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
208
207
|
var hcaptcha = this._hcaptcha;
|
|
209
208
|
//Render hCaptcha widget and provide necessary callbacks - hCaptcha
|
|
210
209
|
var id = hcaptcha.render(this.ref.current, renderParams);
|
|
210
|
+
this.captchaId = id;
|
|
211
211
|
this.setState({
|
|
212
|
-
isRemoved: false
|
|
213
|
-
captchaId: id
|
|
212
|
+
isRemoved: false
|
|
214
213
|
}, function () {
|
|
215
214
|
onRender && onRender();
|
|
216
215
|
onReady && onReady();
|
|
@@ -220,8 +219,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
220
219
|
}, {
|
|
221
220
|
key: "resetCaptcha",
|
|
222
221
|
value: function resetCaptcha() {
|
|
223
|
-
var captchaId = this.state.captchaId;
|
|
224
222
|
var hcaptcha = this._hcaptcha;
|
|
223
|
+
var captchaId = this.captchaId;
|
|
225
224
|
if (!this.isReady()) {
|
|
226
225
|
return;
|
|
227
226
|
}
|
|
@@ -235,8 +234,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
235
234
|
}, {
|
|
236
235
|
key: "removeCaptcha",
|
|
237
236
|
value: function removeCaptcha(callback) {
|
|
238
|
-
var captchaId = this.state.captchaId;
|
|
239
237
|
var hcaptcha = this._hcaptcha;
|
|
238
|
+
var captchaId = this.captchaId;
|
|
240
239
|
if (!this.isReady()) {
|
|
241
240
|
return;
|
|
242
241
|
}
|
|
@@ -279,10 +278,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
279
278
|
key: "handleSubmit",
|
|
280
279
|
value: function handleSubmit(event) {
|
|
281
280
|
var onVerify = this.props.onVerify;
|
|
282
|
-
var
|
|
283
|
-
isRemoved = _this$state2.isRemoved,
|
|
284
|
-
captchaId = _this$state2.captchaId;
|
|
281
|
+
var isRemoved = this.state.isRemoved;
|
|
285
282
|
var hcaptcha = this._hcaptcha;
|
|
283
|
+
var captchaId = this.captchaId;
|
|
286
284
|
if (typeof hcaptcha === 'undefined' || isRemoved) return;
|
|
287
285
|
var token = hcaptcha.getResponse(captchaId); //Get response token from hCaptcha widget
|
|
288
286
|
var ekey = hcaptcha.getRespKey(captchaId); //Get current challenge session id from hCaptcha widget
|
|
@@ -292,8 +290,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
292
290
|
key: "handleExpire",
|
|
293
291
|
value: function handleExpire() {
|
|
294
292
|
var onExpire = this.props.onExpire;
|
|
295
|
-
var captchaId = this.state.captchaId;
|
|
296
293
|
var hcaptcha = this._hcaptcha;
|
|
294
|
+
var captchaId = this.captchaId;
|
|
297
295
|
if (!this.isReady()) {
|
|
298
296
|
return;
|
|
299
297
|
}
|
|
@@ -309,8 +307,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
309
307
|
key: "handleError",
|
|
310
308
|
value: function handleError(event) {
|
|
311
309
|
var onError = this.props.onError;
|
|
312
|
-
var captchaId = this.state.captchaId;
|
|
313
310
|
var hcaptcha = this._hcaptcha;
|
|
311
|
+
var captchaId = this.captchaId;
|
|
314
312
|
if (this.isReady()) {
|
|
315
313
|
// If hCaptcha runs into error, reset captcha - hCaptcha
|
|
316
314
|
hcaptcha.reset(captchaId);
|
|
@@ -320,9 +318,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
320
318
|
}, {
|
|
321
319
|
key: "isReady",
|
|
322
320
|
value: function isReady() {
|
|
323
|
-
var _this$
|
|
324
|
-
isApiReady = _this$
|
|
325
|
-
isRemoved = _this$
|
|
321
|
+
var _this$state = this.state,
|
|
322
|
+
isApiReady = _this$state.isApiReady,
|
|
323
|
+
isRemoved = _this$state.isRemoved;
|
|
326
324
|
return isApiReady && !isRemoved;
|
|
327
325
|
}
|
|
328
326
|
}, {
|
|
@@ -356,8 +354,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
356
354
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
357
355
|
opts = (0, _typeof2["default"])(opts) === 'object' ? opts : null;
|
|
358
356
|
try {
|
|
359
|
-
var captchaId = this.state.captchaId;
|
|
360
357
|
var hcaptcha = this._hcaptcha;
|
|
358
|
+
var captchaId = this.captchaId;
|
|
361
359
|
if (!this.isReady()) {
|
|
362
360
|
var _opts;
|
|
363
361
|
var onReady = new Promise(function (resolve, reject) {
|
|
@@ -388,8 +386,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
388
386
|
}, {
|
|
389
387
|
key: "close",
|
|
390
388
|
value: function close() {
|
|
391
|
-
var captchaId = this.state.captchaId;
|
|
392
389
|
var hcaptcha = this._hcaptcha;
|
|
390
|
+
var captchaId = this.captchaId;
|
|
393
391
|
if (!this.isReady()) {
|
|
394
392
|
return;
|
|
395
393
|
}
|
|
@@ -398,8 +396,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
398
396
|
}, {
|
|
399
397
|
key: "setData",
|
|
400
398
|
value: function setData(data) {
|
|
401
|
-
var captchaId = this.state.captchaId;
|
|
402
399
|
var hcaptcha = this._hcaptcha;
|
|
400
|
+
var captchaId = this.captchaId;
|
|
403
401
|
if (!this.isReady()) {
|
|
404
402
|
return;
|
|
405
403
|
}
|
|
@@ -412,13 +410,13 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
412
410
|
key: "getResponse",
|
|
413
411
|
value: function getResponse() {
|
|
414
412
|
var hcaptcha = this._hcaptcha;
|
|
415
|
-
return hcaptcha.getResponse(this.
|
|
413
|
+
return hcaptcha.getResponse(this.captchaId);
|
|
416
414
|
}
|
|
417
415
|
}, {
|
|
418
416
|
key: "getRespKey",
|
|
419
417
|
value: function getRespKey() {
|
|
420
418
|
var hcaptcha = this._hcaptcha;
|
|
421
|
-
return hcaptcha.getRespKey(this.
|
|
419
|
+
return hcaptcha.getRespKey(this.captchaId);
|
|
422
420
|
}
|
|
423
421
|
}, {
|
|
424
422
|
key: "render",
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -37,12 +37,12 @@ class HCaptcha extends React.Component {
|
|
|
37
37
|
this.ref = React.createRef();
|
|
38
38
|
this.apiScriptRequested = false;
|
|
39
39
|
this.sentryHub = null;
|
|
40
|
+
this.captchaId = '';
|
|
40
41
|
|
|
41
42
|
this.state = {
|
|
42
43
|
isApiReady: false,
|
|
43
44
|
isRemoved: false,
|
|
44
45
|
elementId: props.id,
|
|
45
|
-
captchaId: ''
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -82,8 +82,8 @@ class HCaptcha extends React.Component {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
componentWillUnmount() {
|
|
85
|
-
const { captchaId } = this.state;
|
|
86
85
|
const hcaptcha = this._hcaptcha;
|
|
86
|
+
const captchaId = this.captchaId;
|
|
87
87
|
|
|
88
88
|
if (!this.isReady()) {
|
|
89
89
|
return;
|
|
@@ -171,8 +171,9 @@ class HCaptcha extends React.Component {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
renderCaptcha(onRender) {
|
|
174
|
-
const { isApiReady, captchaId } = this.state;
|
|
175
174
|
const { onReady } = this.props;
|
|
175
|
+
const { isApiReady } = this.state;
|
|
176
|
+
const captchaId = this.captchaId;
|
|
176
177
|
|
|
177
178
|
// Prevent calling hCaptcha render on two conditions:
|
|
178
179
|
// • API is not ready
|
|
@@ -194,8 +195,9 @@ class HCaptcha extends React.Component {
|
|
|
194
195
|
const hcaptcha = this._hcaptcha;
|
|
195
196
|
//Render hCaptcha widget and provide necessary callbacks - hCaptcha
|
|
196
197
|
const id = hcaptcha.render(this.ref.current, renderParams);
|
|
198
|
+
this.captchaId = id;
|
|
197
199
|
|
|
198
|
-
this.setState({ isRemoved: false
|
|
200
|
+
this.setState({ isRemoved: false }, () => {
|
|
199
201
|
onRender && onRender();
|
|
200
202
|
onReady && onReady();
|
|
201
203
|
this._onReady && this._onReady(id);
|
|
@@ -203,8 +205,8 @@ class HCaptcha extends React.Component {
|
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
resetCaptcha() {
|
|
206
|
-
const { captchaId } = this.state;
|
|
207
208
|
const hcaptcha = this._hcaptcha;
|
|
209
|
+
const captchaId = this.captchaId;
|
|
208
210
|
|
|
209
211
|
if (!this.isReady()) {
|
|
210
212
|
return;
|
|
@@ -219,8 +221,8 @@ class HCaptcha extends React.Component {
|
|
|
219
221
|
}
|
|
220
222
|
|
|
221
223
|
removeCaptcha(callback) {
|
|
222
|
-
const { captchaId } = this.state;
|
|
223
224
|
const hcaptcha = this._hcaptcha;
|
|
225
|
+
const captchaId = this.captchaId;
|
|
224
226
|
|
|
225
227
|
if (!this.isReady()) {
|
|
226
228
|
return;
|
|
@@ -262,8 +264,9 @@ class HCaptcha extends React.Component {
|
|
|
262
264
|
|
|
263
265
|
handleSubmit (event) {
|
|
264
266
|
const { onVerify } = this.props;
|
|
265
|
-
const { isRemoved
|
|
267
|
+
const { isRemoved } = this.state;
|
|
266
268
|
const hcaptcha = this._hcaptcha;
|
|
269
|
+
const captchaId = this.captchaId;
|
|
267
270
|
|
|
268
271
|
if (typeof hcaptcha === 'undefined' || isRemoved) return
|
|
269
272
|
|
|
@@ -274,8 +277,8 @@ class HCaptcha extends React.Component {
|
|
|
274
277
|
|
|
275
278
|
handleExpire () {
|
|
276
279
|
const { onExpire } = this.props;
|
|
277
|
-
const { captchaId } = this.state;
|
|
278
280
|
const hcaptcha = this._hcaptcha;
|
|
281
|
+
const captchaId = this.captchaId;
|
|
279
282
|
|
|
280
283
|
if (!this.isReady()) {
|
|
281
284
|
return;
|
|
@@ -293,8 +296,8 @@ class HCaptcha extends React.Component {
|
|
|
293
296
|
|
|
294
297
|
handleError (event) {
|
|
295
298
|
const { onError } = this.props;
|
|
296
|
-
const { captchaId } = this.state;
|
|
297
299
|
const hcaptcha = this._hcaptcha;
|
|
300
|
+
const captchaId = this.captchaId;
|
|
298
301
|
|
|
299
302
|
if (this.isReady()) {
|
|
300
303
|
// If hCaptcha runs into error, reset captcha - hCaptcha
|
|
@@ -339,8 +342,8 @@ class HCaptcha extends React.Component {
|
|
|
339
342
|
opts = typeof opts === 'object' ? opts : null;
|
|
340
343
|
|
|
341
344
|
try {
|
|
342
|
-
const { captchaId } = this.state;
|
|
343
345
|
const hcaptcha = this._hcaptcha;
|
|
346
|
+
const captchaId = this.captchaId;
|
|
344
347
|
|
|
345
348
|
if (!this.isReady()) {
|
|
346
349
|
const onReady = new Promise((resolve, reject) => {
|
|
@@ -374,8 +377,8 @@ class HCaptcha extends React.Component {
|
|
|
374
377
|
}
|
|
375
378
|
|
|
376
379
|
close() {
|
|
377
|
-
const { captchaId } = this.state;
|
|
378
380
|
const hcaptcha = this._hcaptcha;
|
|
381
|
+
const captchaId = this.captchaId;
|
|
379
382
|
|
|
380
383
|
if (!this.isReady()) {
|
|
381
384
|
return;
|
|
@@ -385,8 +388,8 @@ class HCaptcha extends React.Component {
|
|
|
385
388
|
}
|
|
386
389
|
|
|
387
390
|
setData (data) {
|
|
388
|
-
const { captchaId } = this.state;
|
|
389
391
|
const hcaptcha = this._hcaptcha;
|
|
392
|
+
const captchaId = this.captchaId;
|
|
390
393
|
|
|
391
394
|
if (!this.isReady()) {
|
|
392
395
|
return;
|
|
@@ -401,12 +404,12 @@ class HCaptcha extends React.Component {
|
|
|
401
404
|
|
|
402
405
|
getResponse() {
|
|
403
406
|
const hcaptcha = this._hcaptcha;
|
|
404
|
-
return hcaptcha.getResponse(this.
|
|
407
|
+
return hcaptcha.getResponse(this.captchaId);
|
|
405
408
|
}
|
|
406
409
|
|
|
407
410
|
getRespKey() {
|
|
408
411
|
const hcaptcha = this._hcaptcha;
|
|
409
|
-
return hcaptcha.getRespKey(this.
|
|
412
|
+
return hcaptcha.getRespKey(this.captchaId)
|
|
410
413
|
}
|
|
411
414
|
|
|
412
415
|
render () {
|