Add cleanup effect to home and search pages

This commit is contained in:
Hazem Krimi
2020-10-18 19:29:57 +01:00
parent f66590b4b5
commit f06ce416d0
2 changed files with 10 additions and 0 deletions
+5
View File
@@ -139,6 +139,11 @@ const Home: React.FC = () => {
setError('Geolocation not active! Try searching for a city instead'); setError('Geolocation not active! Try searching for a city instead');
} }
); );
return () => {
setError('');
setLoading(true);
}
// eslint-disable-next-line // eslint-disable-next-line
}, []); }, []);
+5
View File
@@ -133,6 +133,11 @@ const Search: React.FC = () => {
setError('No weather data found! Try again later'); setError('No weather data found! Try again later');
} }
})(); })();
return () => {
setError('');
setLoading(true);
}
}, [query]); }, [query]);
return !loading ? ( return !loading ? (