import { useState, useEffect } from 'react' export function useGeolocation() { const [location, setLocation] = useState<{ latitude: number; longitude: number } | null>(null) const [error, setError] = useState(null) useEffect(() => { navigator.geolocation.getCurrentPosition( (pos) => setLocation({ latitude: pos.coords.latitude, longitude: pos.coords.longitude }), (err) => setError(err.message) ) }, []) return { location, error } }