I allow the user to select a language within the app and I store it locally. When they come back in the app, I try using AsyncStorage to fetch the language but when I call
i18n.changeLanguage(currentLanguage)
it causes a memory leakage. here is my code
const [language, setLanguage] = useState('')
const {t} = useTranslation();
const fetchLanguage = async () =>{
try{
const currentLanguage = await AsyncStorage.getItem('language')
if (currentLanguage === null ){
}
else{
setLanguage (currentLanguage)
i18n.changeLanguage(currentLanguage)
}
}catch (e){
console.log(e)
}
}
useEffect (()=>{
fetchLanguage()
}, [])