diff --git a/lib/LanguageContext.tsx b/lib/LanguageContext.tsx index b2b1738..8f386c2 100644 --- a/lib/LanguageContext.tsx +++ b/lib/LanguageContext.tsx @@ -1,4 +1,10 @@ -import React, { createContext, useContext, useState, ReactNode } from "react"; +import React, { + createContext, + useContext, + useState, + ReactNode, + useMemo, +} from "react"; export type Language = "fi" | "sv" | "en"; @@ -16,9 +22,13 @@ export const LanguageProvider: React.FC<{ children: ReactNode }> = ({ children, }) => { const [language, setLanguage] = useState("en"); + const value = useMemo( + () => ({ language, setLanguage }), + [language, setLanguage], + ); return ( - + {children} );