From ae0f5448e44da7463e40f8c534fdf5660d477102 Mon Sep 17 00:00:00 2001 From: HeemahMuslad Date: Fri, 26 Jul 2024 11:57:12 +0100 Subject: [PATCH] update: useeffect: sitekey --- src/components/Recaptcha.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 (