diff --git a/src/components/home/HomePage.tsx b/src/components/home/HomePage.tsx index ddd2b887..76bb1440 100644 --- a/src/components/home/HomePage.tsx +++ b/src/components/home/HomePage.tsx @@ -1,7 +1,9 @@ import { LocationCards } from './LocationCards'; -import type { Location } from '../../types/sparkeats'; +import { useLocations } from '../../useLocations'; + +export function HomePage() { + const locations = useLocations(); -export function HomePage({ locations }: { locations: Location[] }) { return (
Home Header
diff --git a/src/main.tsx b/src/main.tsx index 04e44a9f..1839ecbb 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -3,7 +3,6 @@ import ReactDOM from 'react-dom/client'; import { BrowserRouter, Routes, Route } from 'react-router-dom'; import { App } from './App'; import { HomePage } from './components/home/HomePage'; -import { locations } from './locations'; window.__SPARKEATS_VERSION__ = import.meta.env['VITE_SPARKEATS_VERSION']; @@ -12,7 +11,7 @@ ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( }> - } /> + } /> Location Page
} /> New Location Page} /> New Review Page} /> diff --git a/src/useLocations.ts b/src/useLocations.ts new file mode 100644 index 00000000..0d42a084 --- /dev/null +++ b/src/useLocations.ts @@ -0,0 +1,8 @@ +import React, { useContext } from 'react'; +import { locations } from './locations'; + +const LocationsContext = React.createContext(locations); + +export const LocationsProvider = LocationsContext.Provider; + +export const useLocations = () => useContext(LocationsContext);