Skip to content

Commit

Permalink
update: useeffect: sitekey
Browse files Browse the repository at this point in the history
  • Loading branch information
HeemahMuslad committed Jul 26, 2024
1 parent d2a6cd5 commit ae0f544
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/Recaptcha.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +23,7 @@ function GoogleRecaptcha({ onToken }) {
return () => {
document.body.removeChild(script);
};
}, [onToken]);
}, [onToken, siteKey]);

return (
<div
Expand Down

0 comments on commit ae0f544

Please sign in to comment.