text: import React, { useState, useEffect } from "react";
  export const usePosition = () => {
    const [position, setPosition] = useState({});
    const [error, setError] = useState(null);
  
    const onChange = ({ coords }) => {
      setPosition({
        latitude: coords.latitude,
        longitude: coords.longitude,
        accuracy: coords.accuracy,
      });
    };
    const onError = (error) => {
      setError(error.message);
    };
    useEffect(() => {
      const geo = navigator.geolocation;
      if (!geo) {
        setError("Geolocation is not supported");
        return;
      }
      let watcher = geo.watchPosition(onChange, onError);
      return () => geo.clearWatch(watcher);
    }, []);
    return [position.latitude, position.longitude, position.accuracy, error];
  };
  