diff --git a/src/components/Recaptcha.jsx b/src/components/Recaptcha.jsx index 2e0c0a7..ca5b9d0 100644 --- a/src/components/Recaptcha.jsx +++ b/src/components/Recaptcha.jsx @@ -3,10 +3,10 @@ import React, { useEffect, useRef } from "react"; function GoogleRecaptcha({ onToken }) { const recaptchaRef = useRef(null); const siteKey = process.env.REACT_APP_RECAPTCHA_SITE_KEY; + useEffect(() => { const script = document.createElement("script"); - script.src = - `https://www.google.com/recaptcha/api.js?render=${siteKey}`; + script.src = `https://www.google.com/recaptcha/api.js?render=${siteKey}`; script.addEventListener("load", () => { window.grecaptcha.ready(() => { window.grecaptcha @@ -23,7 +23,7 @@ function GoogleRecaptcha({ onToken }) { return () => { document.body.removeChild(script); }; - }, [onToken]); + }, [onToken, siteKey]); return (