feat: split hooks

This commit is contained in:
TrèsAbhi committed 2026-01-14 12:41:51 -06:00
1 parent 67024daa25
commit 1a18058228
4 files changed
+16 -14

No files matched your search

@@ -3,11 +3,10 @@ import { useAwait } from "./useAwait";
import { useLocale } from "./useLocale";
export function useGameStrings(group: string) {
const { locale } = useLocale();
const locale = useLocale();
const strings = useAwait(
() => api.groupedGameStrings(locale, group, true),
`game-strings-${locale}-${group}`
);
return strings;
}
+1 -8
View File
@@ -1,7 +1,5 @@
import locales from "@blitzkit/i18n/locales.json";
import { createContext, useContext, type ReactNode } from "react";
import { api } from "../core/api/dynamic";
import { useAwait } from "./useAwait";
const LocaleContext = createContext<{
locale: string;
@@ -26,12 +24,7 @@ export function useLocale() {
throw new Error("useLocale must be used within a LocaleProvider");
}
const strings = useAwait(
() => api.strings(context.locale),
`strings-${context.locale}`
);
return { locale: context.locale, strings };
return context.locale;
}
export interface LocaleAcceptorProps {
@@ -0,0 +1,9 @@
import { api } from "../core/api/dynamic";
import { useAwait } from "./useAwait";
import { useLocale } from "./useLocale";
export function useStrings() {
const locale = useLocale();
const strings = useAwait(() => api.strings(locale), `strings-${locale}`);
return strings;
}