"use client"; import { getForecast } from "@/app/actions"; import Temperature from "./Temperature"; import { Forecast, coordType } from "@/types/types"; import { useEffect, useState } from "react"; import { defaultForecast } from "@/app/defaultState"; export default function WeatherNow(props: { geoLocation: coordType }) { // const weather = getForecast(props.geoLocation); const [weather, setWeather] = useState(defaultForecast); useEffect(() => { let mounted = true; getForecast(props.geoLocation).then((data) => { if (mounted) { setWeather(data); } }); return () => { mounted = false; }; }, [props.geoLocation]); return ( <>

Here is the current weather in {weather.name}

); }