From 3530d0e37f8483f777fafc666d67038353c9a85f Mon Sep 17 00:00:00 2001 From: "theis.gaedigk" Date: Tue, 29 Jul 2025 22:40:01 +0200 Subject: [PATCH] refactor: change apiKey variable to a function for better encapsulation in WeatherCard component --- frontend/src/components/WeatherCard.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/WeatherCard.tsx b/frontend/src/components/WeatherCard.tsx index cf682c1..e78bb01 100644 --- a/frontend/src/components/WeatherCard.tsx +++ b/frontend/src/components/WeatherCard.tsx @@ -5,7 +5,7 @@ import Cookies from "js-cookie"; const WeatherCard: React.FC = () => { const [city, setCity] = useState(""); - const apiKey = Cookies.get("apiKey") || ""; + const getAPIKey = () => Cookies.get("apiKey") || ""; const handleCityChange = (event: React.ChangeEvent) => { setCity(event.target.value); @@ -13,7 +13,7 @@ const WeatherCard: React.FC = () => { const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); - fetchWeather(city, apiKey); + fetchWeather(city, getAPIKey()); }; return (