mirror of
https://github.com/hazemKrimi/react-weather-app.git
synced 2026-05-02 02:30:30 +00:00
Add cleanup effect to home and search pages
This commit is contained in:
@@ -139,6 +139,11 @@ const Home: React.FC = () => {
|
||||
setError('Geolocation not active! Try searching for a city instead');
|
||||
}
|
||||
);
|
||||
|
||||
return () => {
|
||||
setError('');
|
||||
setLoading(true);
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -133,6 +133,11 @@ const Search: React.FC = () => {
|
||||
setError('No weather data found! Try again later');
|
||||
}
|
||||
})();
|
||||
|
||||
return () => {
|
||||
setError('');
|
||||
setLoading(true);
|
||||
}
|
||||
}, [query]);
|
||||
|
||||
return !loading ? (
|
||||
|
||||
Reference in New Issue
Block a user