@hcaptcha/react-hcaptcha 1.11.1 → 1.11.3

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 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,14 +201,16 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
202
201
  });
203
202
  };
204
203
  _proto.removeCaptcha = function removeCaptcha(callback) {
205
- var captchaId = this.state.captchaId;
204
+ var _this5 = this;
206
205
  var hcaptcha = this._hcaptcha;
206
+ var captchaId = this.captchaId;
207
207
  if (!this.isReady()) {
208
208
  return;
209
209
  }
210
210
  this.setState({
211
211
  isRemoved: true
212
212
  }, function () {
213
+ _this5.captchaId = '';
213
214
  hcaptcha.remove(captchaId);
214
215
  callback && callback();
215
216
  });
@@ -219,33 +220,32 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
219
220
  });
220
221
  };
221
222
  _proto.handleOnLoad = function handleOnLoad() {
222
- var _this5 = this;
223
+ var _this6 = this;
223
224
  this.setState({
224
225
  isApiReady: true
225
226
  }, function () {
226
227
  try {
227
- var element = getMountElement(_this5.props.scriptLocation);
228
+ var element = getMountElement(_this6.props.scriptLocation);
228
229
  var frame = getFrame(element);
229
- _this5._hcaptcha = frame.window.hcaptcha;
230
+ _this6._hcaptcha = frame.window.hcaptcha;
230
231
 
231
232
  // render captcha and wait for captcha id
232
- _this5.renderCaptcha(function () {
233
+ _this6.renderCaptcha(function () {
233
234
  // trigger onLoad if it exists
234
235
 
235
- var onLoad = _this5.props.onLoad;
236
+ var onLoad = _this6.props.onLoad;
236
237
  if (onLoad) onLoad();
237
238
  });
238
239
  } catch (error) {
239
- _this5.sentryHub.captureException(error);
240
+ _this6.sentryHub.captureException(error);
240
241
  }
241
242
  });
242
243
  };
243
244
  _proto.handleSubmit = function handleSubmit(event) {
244
245
  var onVerify = this.props.onVerify;
245
- var _this$state2 = this.state,
246
- isRemoved = _this$state2.isRemoved,
247
- captchaId = _this$state2.captchaId;
246
+ var isRemoved = this.state.isRemoved;
248
247
  var hcaptcha = this._hcaptcha;
248
+ var captchaId = this.captchaId;
249
249
  if (typeof hcaptcha === 'undefined' || isRemoved) return;
250
250
  var token = hcaptcha.getResponse(captchaId); //Get response token from hCaptcha widget
251
251
  var ekey = hcaptcha.getRespKey(captchaId); //Get current challenge session id from hCaptcha widget
@@ -253,8 +253,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
253
253
  };
254
254
  _proto.handleExpire = function handleExpire() {
255
255
  var onExpire = this.props.onExpire;
256
- var captchaId = this.state.captchaId;
257
256
  var hcaptcha = this._hcaptcha;
257
+ var captchaId = this.captchaId;
258
258
  if (!this.isReady()) {
259
259
  return;
260
260
  }
@@ -268,8 +268,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
268
268
  };
269
269
  _proto.handleError = function handleError(event) {
270
270
  var onError = this.props.onError;
271
- var captchaId = this.state.captchaId;
272
271
  var hcaptcha = this._hcaptcha;
272
+ var captchaId = this.captchaId;
273
273
  if (this.isReady()) {
274
274
  // If hCaptcha runs into error, reset captcha - hCaptcha
275
275
  hcaptcha.reset(captchaId);
@@ -277,9 +277,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
277
277
  if (onError) onError(event);
278
278
  };
279
279
  _proto.isReady = function isReady() {
280
- var _this$state3 = this.state,
281
- isApiReady = _this$state3.isApiReady,
282
- isRemoved = _this$state3.isRemoved;
280
+ var _this$state = this.state,
281
+ isApiReady = _this$state.isApiReady,
282
+ isRemoved = _this$state.isRemoved;
283
283
  return isApiReady && !isRemoved;
284
284
  };
285
285
  _proto.handleOpen = function handleOpen() {
@@ -301,20 +301,20 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
301
301
  this.props.onChalExpired();
302
302
  };
303
303
  _proto.execute = function execute(opts) {
304
- var _this6 = this;
304
+ var _this7 = this;
305
305
  if (opts === void 0) {
306
306
  opts = null;
307
307
  }
308
308
  opts = typeof opts === 'object' ? opts : null;
309
309
  try {
310
- var captchaId = this.state.captchaId;
311
310
  var hcaptcha = this._hcaptcha;
311
+ var captchaId = this.captchaId;
312
312
  if (!this.isReady()) {
313
313
  var _opts;
314
314
  var onReady = new Promise(function (resolve, reject) {
315
- _this6._onReady = function (id) {
315
+ _this7._onReady = function (id) {
316
316
  try {
317
- var _hcaptcha = _this6._hcaptcha;
317
+ var _hcaptcha = _this7._hcaptcha;
318
318
  if (opts && opts.async) {
319
319
  _hcaptcha.execute(id, opts).then(resolve)["catch"](reject);
320
320
  } else {
@@ -337,16 +337,16 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
337
337
  }
338
338
  };
339
339
  _proto.close = function close() {
340
- var captchaId = this.state.captchaId;
341
340
  var hcaptcha = this._hcaptcha;
341
+ var captchaId = this.captchaId;
342
342
  if (!this.isReady()) {
343
343
  return;
344
344
  }
345
345
  return hcaptcha.close(captchaId);
346
346
  };
347
347
  _proto.setData = function setData(data) {
348
- var captchaId = this.state.captchaId;
349
348
  var hcaptcha = this._hcaptcha;
349
+ var captchaId = this.captchaId;
350
350
  if (!this.isReady()) {
351
351
  return;
352
352
  }
@@ -357,11 +357,11 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
357
357
  };
358
358
  _proto.getResponse = function getResponse() {
359
359
  var hcaptcha = this._hcaptcha;
360
- return hcaptcha.getResponse(this.state.captchaId);
360
+ return hcaptcha.getResponse(this.captchaId);
361
361
  };
362
362
  _proto.getRespKey = function getRespKey() {
363
363
  var hcaptcha = this._hcaptcha;
364
- return hcaptcha.getRespKey(this.state.captchaId);
364
+ return hcaptcha.getRespKey(this.captchaId);
365
365
  };
366
366
  _proto.render = function render() {
367
367
  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,14 +234,16 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
235
234
  }, {
236
235
  key: "removeCaptcha",
237
236
  value: function removeCaptcha(callback) {
238
- var captchaId = this.state.captchaId;
237
+ var _this5 = this;
239
238
  var hcaptcha = this._hcaptcha;
239
+ var captchaId = this.captchaId;
240
240
  if (!this.isReady()) {
241
241
  return;
242
242
  }
243
243
  this.setState({
244
244
  isRemoved: true
245
245
  }, function () {
246
+ _this5.captchaId = '';
246
247
  hcaptcha.remove(captchaId);
247
248
  callback && callback();
248
249
  });
@@ -254,24 +255,24 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
254
255
  }, {
255
256
  key: "handleOnLoad",
256
257
  value: function handleOnLoad() {
257
- var _this5 = this;
258
+ var _this6 = this;
258
259
  this.setState({
259
260
  isApiReady: true
260
261
  }, function () {
261
262
  try {
262
- var element = (0, _utils.getMountElement)(_this5.props.scriptLocation);
263
+ var element = (0, _utils.getMountElement)(_this6.props.scriptLocation);
263
264
  var frame = (0, _utils.getFrame)(element);
264
- _this5._hcaptcha = frame.window.hcaptcha;
265
+ _this6._hcaptcha = frame.window.hcaptcha;
265
266
 
266
267
  // render captcha and wait for captcha id
267
- _this5.renderCaptcha(function () {
268
+ _this6.renderCaptcha(function () {
268
269
  // trigger onLoad if it exists
269
270
 
270
- var onLoad = _this5.props.onLoad;
271
+ var onLoad = _this6.props.onLoad;
271
272
  if (onLoad) onLoad();
272
273
  });
273
274
  } catch (error) {
274
- _this5.sentryHub.captureException(error);
275
+ _this6.sentryHub.captureException(error);
275
276
  }
276
277
  });
277
278
  }
@@ -279,10 +280,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
279
280
  key: "handleSubmit",
280
281
  value: function handleSubmit(event) {
281
282
  var onVerify = this.props.onVerify;
282
- var _this$state2 = this.state,
283
- isRemoved = _this$state2.isRemoved,
284
- captchaId = _this$state2.captchaId;
283
+ var isRemoved = this.state.isRemoved;
285
284
  var hcaptcha = this._hcaptcha;
285
+ var captchaId = this.captchaId;
286
286
  if (typeof hcaptcha === 'undefined' || isRemoved) return;
287
287
  var token = hcaptcha.getResponse(captchaId); //Get response token from hCaptcha widget
288
288
  var ekey = hcaptcha.getRespKey(captchaId); //Get current challenge session id from hCaptcha widget
@@ -292,8 +292,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
292
292
  key: "handleExpire",
293
293
  value: function handleExpire() {
294
294
  var onExpire = this.props.onExpire;
295
- var captchaId = this.state.captchaId;
296
295
  var hcaptcha = this._hcaptcha;
296
+ var captchaId = this.captchaId;
297
297
  if (!this.isReady()) {
298
298
  return;
299
299
  }
@@ -309,8 +309,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
309
309
  key: "handleError",
310
310
  value: function handleError(event) {
311
311
  var onError = this.props.onError;
312
- var captchaId = this.state.captchaId;
313
312
  var hcaptcha = this._hcaptcha;
313
+ var captchaId = this.captchaId;
314
314
  if (this.isReady()) {
315
315
  // If hCaptcha runs into error, reset captcha - hCaptcha
316
316
  hcaptcha.reset(captchaId);
@@ -320,9 +320,9 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
320
320
  }, {
321
321
  key: "isReady",
322
322
  value: function isReady() {
323
- var _this$state3 = this.state,
324
- isApiReady = _this$state3.isApiReady,
325
- isRemoved = _this$state3.isRemoved;
323
+ var _this$state = this.state,
324
+ isApiReady = _this$state.isApiReady,
325
+ isRemoved = _this$state.isRemoved;
326
326
  return isApiReady && !isRemoved;
327
327
  }
328
328
  }, {
@@ -352,18 +352,18 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
352
352
  }, {
353
353
  key: "execute",
354
354
  value: function execute() {
355
- var _this6 = this;
355
+ var _this7 = this;
356
356
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
357
357
  opts = (0, _typeof2["default"])(opts) === 'object' ? opts : null;
358
358
  try {
359
- var captchaId = this.state.captchaId;
360
359
  var hcaptcha = this._hcaptcha;
360
+ var captchaId = this.captchaId;
361
361
  if (!this.isReady()) {
362
362
  var _opts;
363
363
  var onReady = new Promise(function (resolve, reject) {
364
- _this6._onReady = function (id) {
364
+ _this7._onReady = function (id) {
365
365
  try {
366
- var _hcaptcha = _this6._hcaptcha;
366
+ var _hcaptcha = _this7._hcaptcha;
367
367
  if (opts && opts.async) {
368
368
  _hcaptcha.execute(id, opts).then(resolve)["catch"](reject);
369
369
  } else {
@@ -388,8 +388,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
388
388
  }, {
389
389
  key: "close",
390
390
  value: function close() {
391
- var captchaId = this.state.captchaId;
392
391
  var hcaptcha = this._hcaptcha;
392
+ var captchaId = this.captchaId;
393
393
  if (!this.isReady()) {
394
394
  return;
395
395
  }
@@ -398,8 +398,8 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
398
398
  }, {
399
399
  key: "setData",
400
400
  value: function setData(data) {
401
- var captchaId = this.state.captchaId;
402
401
  var hcaptcha = this._hcaptcha;
402
+ var captchaId = this.captchaId;
403
403
  if (!this.isReady()) {
404
404
  return;
405
405
  }
@@ -412,13 +412,13 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
412
412
  key: "getResponse",
413
413
  value: function getResponse() {
414
414
  var hcaptcha = this._hcaptcha;
415
- return hcaptcha.getResponse(this.state.captchaId);
415
+ return hcaptcha.getResponse(this.captchaId);
416
416
  }
417
417
  }, {
418
418
  key: "getRespKey",
419
419
  value: function getRespKey() {
420
420
  var hcaptcha = this._hcaptcha;
421
- return hcaptcha.getRespKey(this.state.captchaId);
421
+ return hcaptcha.getRespKey(this.captchaId);
422
422
  }
423
423
  }, {
424
424
  key: "render",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hcaptcha/react-hcaptcha",
3
- "version": "1.11.1",
3
+ "version": "1.11.3",
4
4
  "types": "types/index.d.ts",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
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, captchaId: id }, () => {
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,14 +221,16 @@ 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;
227
229
  }
228
230
 
229
231
  this.setState({ isRemoved: true }, () => {
232
+ this.captchaId = '';
233
+
230
234
  hcaptcha.remove(captchaId);
231
235
  callback && callback()
232
236
  });
@@ -262,8 +266,9 @@ class HCaptcha extends React.Component {
262
266
 
263
267
  handleSubmit (event) {
264
268
  const { onVerify } = this.props;
265
- const { isRemoved, captchaId } = this.state;
269
+ const { isRemoved } = this.state;
266
270
  const hcaptcha = this._hcaptcha;
271
+ const captchaId = this.captchaId;
267
272
 
268
273
  if (typeof hcaptcha === 'undefined' || isRemoved) return
269
274
 
@@ -274,8 +279,8 @@ class HCaptcha extends React.Component {
274
279
 
275
280
  handleExpire () {
276
281
  const { onExpire } = this.props;
277
- const { captchaId } = this.state;
278
282
  const hcaptcha = this._hcaptcha;
283
+ const captchaId = this.captchaId;
279
284
 
280
285
  if (!this.isReady()) {
281
286
  return;
@@ -293,8 +298,8 @@ class HCaptcha extends React.Component {
293
298
 
294
299
  handleError (event) {
295
300
  const { onError } = this.props;
296
- const { captchaId } = this.state;
297
301
  const hcaptcha = this._hcaptcha;
302
+ const captchaId = this.captchaId;
298
303
 
299
304
  if (this.isReady()) {
300
305
  // If hCaptcha runs into error, reset captcha - hCaptcha
@@ -339,8 +344,8 @@ class HCaptcha extends React.Component {
339
344
  opts = typeof opts === 'object' ? opts : null;
340
345
 
341
346
  try {
342
- const { captchaId } = this.state;
343
347
  const hcaptcha = this._hcaptcha;
348
+ const captchaId = this.captchaId;
344
349
 
345
350
  if (!this.isReady()) {
346
351
  const onReady = new Promise((resolve, reject) => {
@@ -374,8 +379,8 @@ class HCaptcha extends React.Component {
374
379
  }
375
380
 
376
381
  close() {
377
- const { captchaId } = this.state;
378
382
  const hcaptcha = this._hcaptcha;
383
+ const captchaId = this.captchaId;
379
384
 
380
385
  if (!this.isReady()) {
381
386
  return;
@@ -385,8 +390,8 @@ class HCaptcha extends React.Component {
385
390
  }
386
391
 
387
392
  setData (data) {
388
- const { captchaId } = this.state;
389
393
  const hcaptcha = this._hcaptcha;
394
+ const captchaId = this.captchaId;
390
395
 
391
396
  if (!this.isReady()) {
392
397
  return;
@@ -401,12 +406,12 @@ class HCaptcha extends React.Component {
401
406
 
402
407
  getResponse() {
403
408
  const hcaptcha = this._hcaptcha;
404
- return hcaptcha.getResponse(this.state.captchaId);
409
+ return hcaptcha.getResponse(this.captchaId);
405
410
  }
406
411
 
407
412
  getRespKey() {
408
413
  const hcaptcha = this._hcaptcha;
409
- return hcaptcha.getRespKey(this.state.captchaId)
414
+ return hcaptcha.getRespKey(this.captchaId)
410
415
  }
411
416
 
412
417
  render () {