reagir dados buscar dados (clima)
interface WeatherDisplayProps {
location: string;
}
const WeatherDisplay: FC<WeatherDisplayProps> = ({ location }) => {
const [weather, setWeather] = useState<number>();
useEffect(() => {
const fetchWeather = async () => {
const response = await WeatherAPI.getWeather(location);
setWeather(response.celsius);
};
fetchWeather();
}, [location]);
return (
<div>
<h1>Weather</h1>
<p>
Today weather in {location} is {weather} celsius{" "}
</p>
</div>
);
};
export default WeatherDisplay;
Puzzled Puffin