fix: i18n client hydration error
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
"use client"
|
||||
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useState } from "react"
|
||||
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
import { useRefCallback } from "@crossbell/util-hooks"
|
||||
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { getSubscriptionsFromList } from "~/models/site.model"
|
||||
import { useSubscribeToSites } from "~/queries/site"
|
||||
|
||||
|
||||
@@ -7,11 +7,13 @@ import { FollowAllButton } from "~/components/common/FollowAllButton"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { useGetShowcase } from "~/queries/home"
|
||||
|
||||
export function ShowCase() {
|
||||
const showcaseSites = useGetShowcase()
|
||||
const [showcaseMore, setShowcaseMore] = useState(false)
|
||||
const { t } = useTranslation("index")
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -35,8 +37,7 @@ export function ShowCase() {
|
||||
}`}
|
||||
onClick={() => setShowcaseMore(true)}
|
||||
>
|
||||
{/* {t("Show more")} */}
|
||||
Show more
|
||||
{t("Show more")}
|
||||
</div>
|
||||
{showcaseSites.data?.map((site) => (
|
||||
<li className="inline-flex align-middle" key={site.handle}>
|
||||
|
||||
+14
-2
@@ -3,12 +3,13 @@
|
||||
import i18next from "i18next"
|
||||
import LanguageDetector from "i18next-browser-languagedetector"
|
||||
import resourcesToBackend from "i18next-resources-to-backend"
|
||||
import { useEffect, useState } from "react"
|
||||
import {
|
||||
initReactI18next,
|
||||
useTranslation as useTranslationOrg,
|
||||
} from "react-i18next"
|
||||
|
||||
import { getOptions } from "./settings"
|
||||
import { fallbackLng, getOptions } from "./settings"
|
||||
|
||||
i18next
|
||||
.use(initReactI18next)
|
||||
@@ -28,5 +29,16 @@ i18next
|
||||
})
|
||||
|
||||
export function useTranslation(ns: string) {
|
||||
return useTranslationOrg(ns)
|
||||
const [value, setValue] = useState({
|
||||
t: i18next.getFixedT(fallbackLng, ns),
|
||||
})
|
||||
|
||||
const { t } = useTranslationOrg(ns)
|
||||
useEffect(() => {
|
||||
setValue({
|
||||
t,
|
||||
})
|
||||
}, [t])
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user