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

Here is the current weather in {weather.name}

); }