From d9c6ff2507d8edc75df762835cce8dc45d727839 Mon Sep 17 00:00:00 2001 From: Resulte Lee Date: Wed, 22 Jun 2022 18:31:18 +0800 Subject: [PATCH] fix: captcha widget JS warnings (#820) --- web/src/common/CaptchaWidget.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/src/common/CaptchaWidget.js b/web/src/common/CaptchaWidget.js index bfbc4193..b5fb50ed 100644 --- a/web/src/common/CaptchaWidget.js +++ b/web/src/common/CaptchaWidget.js @@ -30,7 +30,7 @@ export const CaptchaWidget = ({ captchaType, siteKey, onChange }) => { if (!window.grecaptcha) { loadScript("https://recaptcha.net/recaptcha/api.js"); } - if (window.grecaptcha) { + if (window.grecaptcha && window.grecaptcha.render) { window.grecaptcha.render("captcha", { sitekey: siteKey, callback: onChange, @@ -44,7 +44,7 @@ export const CaptchaWidget = ({ captchaType, siteKey, onChange }) => { if (!window.hcaptcha) { loadScript("https://js.hcaptcha.com/1/api.js"); } - if (window.hcaptcha) { + if (window.hcaptcha && window.hcaptcha.render) { window.hcaptcha.render("captcha", { sitekey: siteKey, callback: onChange, @@ -56,6 +56,7 @@ export const CaptchaWidget = ({ captchaType, siteKey, onChange }) => { default: break; } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [captchaType, siteKey]); return
;