File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2+ import { flushSync } from 'react-dom' ;
23import { hCaptchaLoader } from '@hcaptcha/loader' ;
34
45import { getFrame , getMountElement } from '../utils.js' ;
@@ -252,20 +253,21 @@ export class HCaptcha extends React.Component {
252253 }
253254
254255 handleOnLoad ( ) {
255- this . setState ( { isApiReady : true } , ( ) => {
256- const element = getMountElement ( this . props . scriptLocation ) ;
257- const frame = getFrame ( element ) ;
256+ const element = getMountElement ( this . props . scriptLocation ) ;
257+ const frame = getFrame ( element ) ;
258258
259- this . _hcaptcha = frame . window . hcaptcha ;
259+ this . _hcaptcha = frame . window . hcaptcha ;
260260
261+ flushSync ( ( ) => {
262+ this . setState ( { isApiReady : true } ) ;
263+ } ) ;
261264
262- // render captcha and wait for captcha id
263- this . renderCaptcha ( ( ) => {
264- // trigger onLoad if it exists
265+ // render captcha and wait for captcha id
266+ this . renderCaptcha ( ( ) => {
267+ // trigger onLoad if it exists
265268
266- const { onLoad } = this . props ;
267- if ( onLoad ) onLoad ( ) ;
268- } ) ;
269+ const { onLoad } = this . props ;
270+ if ( onLoad ) onLoad ( ) ;
269271 } ) ;
270272 }
271273
Original file line number Diff line number Diff line change 11{
22 "name" : " @hcaptcha/react-hcaptcha" ,
33 "description" : " A React library for hCaptcha" ,
4- "version" : " 2.1 .0" ,
4+ "version" : " 2.2 .0" ,
55 "author" : " hCaptcha team and contributors" ,
66 "license" : " MIT" ,
77 "repository" : {
You can’t perform that action at this time.
0 commit comments