removed loading state and fixed bug with that
This commit is contained in:
@@ -9,7 +9,6 @@ import { X } from "lucide-react";
|
|||||||
|
|
||||||
const WeatherCard: React.FC = () => {
|
const WeatherCard: React.FC = () => {
|
||||||
const [city, setCity] = useState("");
|
const [city, setCity] = useState("");
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
const [weatherData, setWeatherData] = useState(false);
|
const [weatherData, setWeatherData] = useState(false);
|
||||||
const getAPIKey = () => Cookies.get("apiKey") || "";
|
const getAPIKey = () => Cookies.get("apiKey") || "";
|
||||||
const getUnit = () => localStorage.getItem("unit") || "metric";
|
const getUnit = () => localStorage.getItem("unit") || "metric";
|
||||||
@@ -20,7 +19,6 @@ const WeatherCard: React.FC = () => {
|
|||||||
|
|
||||||
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setLoading(true);
|
|
||||||
toast
|
toast
|
||||||
.promise(fetchWeather(city, getAPIKey(), getUnit()), {
|
.promise(fetchWeather(city, getAPIKey(), getUnit()), {
|
||||||
pending: "Fetching weather data...",
|
pending: "Fetching weather data...",
|
||||||
@@ -34,7 +32,6 @@ const WeatherCard: React.FC = () => {
|
|||||||
} else {
|
} else {
|
||||||
setWeatherData(false);
|
setWeatherData(false);
|
||||||
}
|
}
|
||||||
setLoading(false);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user