Fixes a crash caused by too many redraws (#759)

This commit is contained in:
Alex van Andel 2021-09-23 23:30:09 +01:00 committed by GitHub
parent b741559dbc
commit ad3a06384f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,4 @@
import { useTranslation } from "next-i18next";
import { useEffect } from "react";
type LocaleProps = {
localeProp: string;
@ -8,9 +7,9 @@ type LocaleProps = {
export const useLocale = (props: LocaleProps) => {
const { i18n, t } = useTranslation("common");
useEffect(() => {
(async () => await i18n.changeLanguage(props.localeProp))();
}, [i18n, props.localeProp]);
if (i18n.language !== props.localeProp) {
i18n.changeLanguage(props.localeProp);
}
return {
i18n,