mirror of
https://github.com/hazemKrimi/react-weather-app.git
synced 2026-05-01 18:30:25 +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');
|
setError('Geolocation not active! Try searching for a city instead');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
setError('');
|
||||||
|
setLoading(true);
|
||||||
|
}
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -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 ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user