local-weather/app/page.tsx

28 lines
871 B
TypeScript
Raw Normal View History

2024-05-05 20:55:51 +00:00
'use client'
2024-05-04 21:04:30 +00:00
import LocationSearch from '@/components/LocationSearch';
import WeatherNow from '../components/WeatherNow'
import { createContext, useState } from 'react';
import { defaultGeoLocation } from './defaultState';
import { LocationContextType, coordType } from '@/types/types';
import { LocationContext } from '@/context/LocationContext';
2024-05-04 07:39:10 +00:00
export default function Home() {
const [geoLocation, setGeoLocation] = useState<coordType>(defaultGeoLocation);
// Create an object that will be passed to the context provider
const contextValue: LocationContextType = {
geoLocation,
setGeoLocation
};
2024-05-04 07:39:10 +00:00
return (
2024-05-10 17:23:02 +00:00
<main>
<div className='mx-auto max-w-3xl text-center'>
<LocationContext.Provider value={contextValue}>
<LocationSearch />
<WeatherNow />
</LocationContext.Provider>
2024-05-04 21:04:30 +00:00
</div>
2024-05-03 14:48:24 +00:00
</main>
);
2024-05-04 13:40:23 +00:00
}