Created
August 31, 2021 19:55
-
-
Save javierguzman/ef7ef7cfa10d0855555901d1bd4e6069 to your computer and use it in GitHub Desktop.
Handling i18next cookies depending on whether the user accepts them or not
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LanguageManager: React.FC = ({ children }): JSX.Element => { | |
const { areCookiesSaved } = useSelector(selectCookiesConsent); | |
const [languageManagerCurrentInstance, setLanguageManagerCurrentInstance] = useState( | |
getInitialLanguageManager() | |
); | |
useEffect(() => { | |
if (areCookiesSaved) { | |
setLanguageManagerCurrentInstance(getLanguageManagerWithCookies()); | |
} | |
}, [areCookiesSaved]); | |
return <I18nextProvider i18n={languageManagerCurrentInstance}>{children}</I18nextProvider>; | |
}; | |
export { LanguageManager }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment