ensure pre-rendering does not fail
This commit is contained in:
		| @@ -7,7 +7,7 @@ import ReCAPTCHA from "react-google-recaptcha"; | ||||
| export default function ContactComponent({ | ||||
|   recaptchaSiteKey, | ||||
| }: { | ||||
|   recaptchaSiteKey: string; | ||||
|   recaptchaSiteKey: string | undefined; | ||||
| }) { | ||||
|   const inputStyle = { | ||||
|     backgroundColor: "#111", | ||||
| @@ -57,7 +57,7 @@ export default function ContactComponent({ | ||||
|             {"success" in state && "Submitted successfully!"} | ||||
|           </span> | ||||
|         )} | ||||
|         <ReCAPTCHA sitekey={recaptchaSiteKey} theme="dark" /> | ||||
|         <ReCAPTCHA sitekey={recaptchaSiteKey ?? ""} theme="dark" /> | ||||
|         <button | ||||
|           type="submit" | ||||
|           style={{ | ||||
| @@ -71,7 +71,7 @@ export default function ContactComponent({ | ||||
|           onMouseLeave={(e) => { | ||||
|             if (!pending) e.currentTarget.style.backgroundColor = "#111"; | ||||
|           }} | ||||
|           disabled={pending} | ||||
|           disabled={pending || recaptchaSiteKey == null} | ||||
|         > | ||||
|           {pending ? "Sending..." : "Submit"} | ||||
|         </button> | ||||
|   | ||||
| @@ -4,9 +4,5 @@ import ContactComponent from "./ContactComponent"; | ||||
|  | ||||
| export default async function ContactPage() { | ||||
|   const recaptchaSiteKey = process.env.RECAPTCHA_SITE_KEY; | ||||
|   if (!recaptchaSiteKey) { | ||||
|     console.error("ReCAPTCHA site key is not set"); | ||||
|     throw new Error("ReCAPTCHA not correctly configured"); | ||||
|   } | ||||
|   return <ContactComponent recaptchaSiteKey={recaptchaSiteKey} />; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user