Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions lib/src/component/HCaptcha.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { flushSync } from 'react-dom';
import { hCaptchaLoader } from '@hcaptcha/loader';

import { getFrame, getMountElement } from '../utils.js';
Expand Down Expand Up @@ -252,20 +253,21 @@ export class HCaptcha extends React.Component {
}

handleOnLoad () {
this.setState({ isApiReady: true }, () => {
const element = getMountElement(this.props.scriptLocation);
const frame = getFrame(element);
const element = getMountElement(this.props.scriptLocation);
const frame = getFrame(element);

this._hcaptcha = frame.window.hcaptcha;
this._hcaptcha = frame.window.hcaptcha;

flushSync(() => {
this.setState({ isApiReady: true });
});

// render captcha and wait for captcha id
this.renderCaptcha(() => {
// trigger onLoad if it exists
// render captcha and wait for captcha id
this.renderCaptcha(() => {
// trigger onLoad if it exists

const { onLoad } = this.props;
if (onLoad) onLoad();
});
const { onLoad } = this.props;
if (onLoad) onLoad();
});
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hcaptcha/react-hcaptcha",
"description": "A React library for hCaptcha",
"version": "2.1.0",
"version": "2.2.0",
"author": "hCaptcha team and contributors",
"license": "MIT",
"repository": {
Expand Down
Loading