diff --git a/hooks/translation.ts b/hooks/translation.ts deleted file mode 100644 index 92192b5..0000000 --- a/hooks/translation.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { atomFamily, useRecoilValueLoadable } from "recoil"; -import { - Dictionary, - fetchTranslationDictionary, -} from "../adapters/translation"; -import { useRouter } from "../hooks/router"; - -const translationAtom = atomFamily({ - key: "Translation", - default: null, - effects_UNSTABLE: (locale) => [ - ({ setSelf, resetSelf }) => { - setSelf(fetchTranslationDictionary(locale)); - - return () => resetSelf(); - }, - ], -}); - -export function useTranslationDictionary() { - const { locale } = useRouter(); - - if (!locale) { - throw new Error("No locale identifier found in the router."); - } - - const dictionaryLoadable = useRecoilValueLoadable(translationAtom(locale)); - - return { - dictionary: dictionaryLoadable.contents, - isLoading: dictionaryLoadable.state === "loading", - }; -} diff --git a/pages/_app.tsx b/pages/_app.tsx index e6e7f16..70cd3a4 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -9,7 +9,6 @@ import { IntlProvider } from "react-intl"; import TopLoadingBar from "react-top-loading-bar"; import { RecoilRoot } from "recoil"; import { useRouter } from "../hooks/router"; -import { useTranslationDictionary } from "../hooks/translation"; import { useUserMonitoring } from "../hooks/user-monitoring"; import "normalize.css/normalize.css"; @@ -47,7 +46,6 @@ const App: React.FC = ({ Component, pageProps }) => { const router = useRouter(); const { trackPageView } = useUserMonitoring(); const topLoadingBarRef = React.useRef(null); - const { dictionary } = useTranslationDictionary(); React.useEffect(() => { const onRouteChangeStart = () => { @@ -91,7 +89,7 @@ const App: React.FC = ({ Component, pageProps }) => {