@@ -3,7 +3,8 @@ import { useState, useEffect } from "preact/hooks"
33import MailchimpSubscribe from "react-mailchimp-subscribe"
44import SubscribeSvg from "~/assets/svgs/footer/subscribe.svg?react"
55import { clsx } from "~/lib"
6- import i18next , { changeLanguage , t } from "i18next"
6+ import { t } from "i18next"
7+ import { useI18nReady } from "~/hooks/useI18nReady"
78
89import EmailInput from "./EmailInput.tsx"
910import styles from "./Subscribe.module.css"
@@ -19,8 +20,7 @@ export default function Subscribe(props) {
1920 const [ email , setEmail ] = useState ( "" )
2021 const [ customMessage , setCustomMessage ] = useState ( "" )
2122 const [ emailValid , setEmailValid ] = useState ( false )
22-
23- i18next . changeLanguage ( props . lang )
23+ const isReady = useI18nReady ( props . lang )
2424
2525 useEffect ( ( ) => {
2626 setCustomMessage ( "" )
@@ -42,6 +42,10 @@ export default function Subscribe(props) {
4242 setEmail ( e . target . value )
4343 }
4444
45+ if ( ! isReady ) {
46+ return null
47+ }
48+
4549 return (
4650 < div className = { clsx ( styles . container , "dark:bg-dark-highlight" ) } >
4751 < div className = { styles . subscribeBox } >
@@ -50,22 +54,28 @@ export default function Subscribe(props) {
5054 </ span >
5155
5256 < div className = { styles . copyBox } >
53- < div className = { styles . subscribeTitle } > { t ( "landing.NewsletterCTA.title" ) } </ div >
54- < div className = { styles . subscribeText } >
55- { t ( "landing.NewsletterCTA.text" ) }
56- </ div >
57+ < div className = { styles . subscribeTitle } > { t ( "landing.NewsletterCTA.title" ) } </ div >
58+ < div className = { styles . subscribeText } > { t ( "landing.NewsletterCTA.text" ) } </ div >
5759 </ div >
5860 < MailchimpSubscribe
5961 url = { url }
60- render = { ( { subscribe, status, message } : any ) => (
62+ render = { ( {
63+ subscribe,
64+ status,
65+ message,
66+ } : {
67+ subscribe : ( data : { EMAIL : string } ) => void
68+ status : string
69+ message : string
70+ } ) => (
6171 < div className = { styles . emailBox } >
6272 < EmailInput
6373 className = { styles . emailInput }
6474 value = { email }
6575 onChange = { handleChangeEmail }
6676 onClick = { ( ) => handleSubmit ( subscribe ) }
6777 onEnter = { ( ) => handleSubmit ( subscribe ) }
68- placeholder = { t ( "landing.NewsletterCTA.placeholder" ) }
78+ placeholder = { t ( "landing.NewsletterCTA.placeholder" ) }
6979 end = { status === "success" }
7080 />
7181 { customMessage && < div className = { styles . errorMessage } > { customMessage } </ div > }
0 commit comments