moved context to separate file and imported
Some checks failed
Docker Build & Publish / Build Docker (push) Failing after 1m10s

This commit is contained in:
ChrQR 2024-05-11 01:21:34 +02:00
parent fe9599334f
commit b8d543e1c1
4 changed files with 11 additions and 8 deletions

View File

@ -4,12 +4,7 @@ import WeatherNow from '../components/WeatherNow'
import { createContext, useState } from 'react';
import { defaultGeoLocation } from './defaultState';
import { LocationContextType, coordType } from '@/types/types';
export const LocationContext = createContext<LocationContextType>({
geoLocation: defaultGeoLocation,
setGeoLocation: () => {} // Default function, does nothing
});
import { LocationContext } from '@/context/LocationContext';
export default function Home() {
const [geoLocation, setGeoLocation] = useState<coordType>(defaultGeoLocation);

View File

@ -1,7 +1,7 @@
"use client";
import React, { useContext, useState } from "react";
import { getLocation } from "@/app/actions";
import { LocationContext } from "@/app/page";
import { LocationContext } from "@/context/LocationContext";
export default function LocationSearch() {
const [searchLocation, setSearchLocation] = useState("");

View File

@ -5,7 +5,7 @@ import Temperature from "./Temperature";
import { HourlyCardPropType, HourlyForecast, WeatherContextType } from "@/types/types";
import { createContext, useContext, useEffect, useState } from "react";
import { defaultHourlyForecast } from "@/app/defaultState";
import { LocationContext } from "@/app/page";
import { LocationContext } from "@/context/LocationContext";
import WeatherHero from "./WeatherHero";
import HourlyCard from "./HourlyCard/HourlyCard";

View File

@ -0,0 +1,8 @@
import { createContext } from 'react';
import { LocationContextType, coordType } from '@/types/types';
import { defaultGeoLocation } from '../app/defaultState';
export const LocationContext = createContext<LocationContextType>({
geoLocation: defaultGeoLocation,
setGeoLocation: () => {} // Default function, does nothing
});