weathericon
This commit is contained in:
		
							parent
							
								
									b3c7724c12
								
							
						
					
					
						commit
						30518a0fba
					
				@ -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)}
 | 
			
		||||
    </>
 | 
			
		||||
)
 | 
			
		||||
};
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user