9 lines
378 B
TypeScript
9 lines
378 B
TypeScript
import { useContext } from 'react'
|
|
import { LocationContext } from '../context/LocationContext'
|
|
|
|
export function useUserLocation() {
|
|
const ctx = useContext(LocationContext)
|
|
if (!ctx) throw new Error('useUserLocation must be used within a LocationProvider')
|
|
const { location, loading, error, requestLocation } = ctx
|
|
return { location, loading, error, requestLocation }
|
|
}
|