"use client";

import { useRef } from "react";
import { useTranslation, type UseTranslationOptions } from "react-i18next";

/** 稳定引用 i18n `t`，避免放进 useCallback/useEffect 依赖导致重复请求 */
export function useTranslationRef(ns?: string | string[], options?: UseTranslationOptions<string>) {
  const { t } = useTranslation(ns, options);
  const tRef = useRef(t);
  tRef.current = t;
  return tRef;
}
