From 1073001e66b7b9dfb99bf5c186d8cfd7c93791af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Xalambr=C3=AD?= Date: Mon, 5 Aug 2024 14:41:34 -0500 Subject: [PATCH] Fix code quality --- src/react.tsx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/react.tsx b/src/react.tsx index 9e1cbb9..a947dad 100644 --- a/src/react.tsx +++ b/src/react.tsx @@ -12,14 +12,14 @@ import { useTranslation } from "react-i18next"; * let formattedDate = date.toLocaleDateString(locale); */ export function useLocale(localeKey = "locale"): string { - let matches = useMatches(); - // biome-ignore lint/style/noNonNullAssertion: There's always a root match - let rootMatch = matches.at(0)!; - let { [localeKey]: locale } = - (rootMatch.data as Record) ?? {}; - if (!locale) throw new Error("Missing locale returned by the root loader."); - if (typeof locale === "string") return locale; - throw new Error("Invalid locale returned by the root loader."); + let matches = useMatches(); + // biome-ignore lint/style/noNonNullAssertion: There's always a root match + let rootMatch = matches.at(0)!; + let { [localeKey]: locale } = + (rootMatch.data as Record) ?? {}; + if (!locale) throw new Error("Missing locale returned by the root loader."); + if (typeof locale === "string") return locale; + throw new Error("Invalid locale returned by the root loader."); } /** @@ -28,8 +28,8 @@ export function useLocale(localeKey = "locale"): string { * This will ensure translations are loaded automatically. */ export function useChangeLanguage(locale: string) { - let { i18n } = useTranslation(); - React.useEffect(() => { - i18n.changeLanguage(locale); - }, [locale, i18n]); + let { i18n } = useTranslation(); + React.useEffect(() => { + i18n.changeLanguage(locale); + }, [locale, i18n]); }