weathericon

This commit is contained in:
christian 2024-05-10 11:50:14 +02:00
parent b3c7724c12
commit 30518a0fba

View File

@ -17,8 +17,7 @@ import { HourlyForecast } from "@/types/types";
function getCurrentWeatherIcon(weather: HourlyForecast) {
const weatherCode = weather.current.weather_code;
function getCurrentWeatherIcon(weatherCode: number) {
switch (weatherCode) {
default:
return sun;
@ -84,10 +83,11 @@ function getCurrentWeatherIcon(weather: HourlyForecast) {
export default function WeatherIcon() {
const { weather } = useContext(WeatherContext)
const weatherCode = weather.current.weather_code
return(
<>
<Image src={getCurrentWeatherIcon(weather)} alt="Weather icon"/>
<p>{weather.current.weather_code}</p>
<Image src={getCurrentWeatherIcon(weatherCode)} alt="Weather icon"/>
{console.log(weatherCode)}
</>
)
};