diff --git a/src/pages/Weather-app/index.jsx b/src/pages/Weather-app/index.jsx index 4fe6595..3368ae2 100644 --- a/src/pages/Weather-app/index.jsx +++ b/src/pages/Weather-app/index.jsx @@ -6,7 +6,8 @@ import { FaMapPin, FaWind } from "react-icons/fa6"; import { WiHumidity } from "react-icons/wi"; const WeatherApp = () => { - const [search, setSearch] = useState(""); + const [search, setSearch] = useState("marrakech"); + const [input, setInput] = useState(""); const [loading, setLoading] = useState(false); const [weatherData, setWeatherData] = useState(null); @@ -30,7 +31,7 @@ const WeatherApp = () => { } function handleSearch() { - fetchWeatherData(search); + setSearch(input); } function getCurrentDate() { @@ -43,18 +44,14 @@ const WeatherApp = () => { } useEffect(() => { - fetchWeatherData("marrakech"); - }, []); + fetchWeatherData(search); + }, [search]); console.log(weatherData); return (