diff --git a/components/Switch.tsx b/components/Switch.tsx index 863a87a..861c495 100644 --- a/components/Switch.tsx +++ b/components/Switch.tsx @@ -2,7 +2,7 @@ import getEnv from "@/lib/env-entry" import { cn } from "@/lib/utils" -import { useTranslations } from "next-intl" +import { useLocale, useTranslations } from "next-intl" import { createRef, useEffect, useRef, useState } from "react" export default function Switch({ @@ -19,6 +19,7 @@ export default function Switch({ const scrollRef = useRef(null) const tagRefs = useRef(allTag.map(() => createRef())) const t = useTranslations("ServerListClient") + const locale = useLocale() const [indicator, setIndicator] = useState<{ x: number; w: number }>({ x: 0, w: 0, @@ -58,7 +59,7 @@ export default function Switch({ w: currentTagElement.offsetWidth, }) } - }, [nowTag]) + }, [nowTag, locale]) useEffect(() => { const currentTagElement = tagRefs.current[allTag.indexOf(nowTag)]?.current @@ -75,7 +76,7 @@ export default function Switch({ behavior: "smooth", }) } - }, [nowTag]) + }, [nowTag, locale]) return (
([]) + const locale = useLocale() useEffect(() => { const currentTabElement = tabRefs.current[tabs.indexOf(currentTab)] @@ -32,7 +33,7 @@ export default function TabSwitch({ w: currentTabElement.offsetWidth, }) } - }, [currentTab, tabs]) + }, [currentTab, tabs, locale]) return (