Recaptcha v2 throws an error when it is reset and its container element is removed from DOM

前端 未结 2 1894
醉酒成梦
醉酒成梦 2021-02-04 08:10

When I explicitly render Recaptcha v2 and then reset it before removing it from the DOM, after ~40 seconds I get an error in the browser console.

I have a JSFiddle which

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-04 08:49

    The error is thrown because captcha has sent calls to google and it wants to receive response but as we remove the element so the response doesn't go according to plan and zone error is thrown, a better approach is to just hide the captcha once you have received the firebase.auth.signInWithPhoneNumber function's response. No need to set any timeouts and call captcha.clear() method in the destroy event of your page.

提交回复
热议问题