import React, { useEffect, useState } from 'react'; const WeatherList = () => { const [weatherArray, setWeatherArray] = useState([]); const [weatherArrayAfterFilter, setWeatherArrayAfterFilter] = useState([]); useEffect(()=>{ fetch('https://danepubliczne.imgw.pl/api/data/synop/') .then(resp=>resp.json()) .then(weather=>{ setWeatherArray(weather); setWeatherArrayAfterFilter(weather); }); }, []); let weatherBoxes = weatherArrayAfterFilter.map(cityWeather=>{ return (

{cityWeather.stacja}

{cityWeather.temperatura} st. C.

{cityWeather.cisnienie} hPa

); }); const filterWeather = e => { let filteredWeatherArray = weatherArray.filter(cityWeather=>{ return cityWeather.stacja.toUpperCase().includes(e.target.value.toUpperCase()); }); setWeatherArrayAfterFilter(filteredWeatherArray); } return (
{weatherBoxes}
) } export default WeatherList;