setTimeout is causing memory leaks.
bleedingAyush opened this issue · comments
Ayush kumar commented
The setTimeout function which you are using in App.js is causing memory leaks. To fix this you can clear the timeout
useEffect(() => {
const timeout = setTimeout(async() => {
let userToken;
userToken = null;
try {
userToken = await AsyncStorage.getItem('userToken');
} catch(e) {
console.log(e);
}
dispatch({ type: 'RETRIEVE_TOKEN', token: userToken });
}, 1000);
return = () => {
timeout()
}
}, []);