Skip to content

Latitude and longitude does not get updated after geolocation changeΒ #21

@7hong13

Description

@7hong13

Hi, I want to update latitude and longitude as browser detects geolocation change.
So I just followed what document says, but it doesn't seem to work.
It always returns the same latitude and longitude about where I called usePosition() for the very first time.
I can't figure out what the problem is.
Below is my code:

  const watch = true;
  const [currPosition, setCurrPosition] = useState({
    lat: 0,
    long: 0,
  })
  const { latitude, longitude, timestamp, accuracy, error } = usePosition(
    watch,
    { enableHighAccuracy: true }
  );
 useEffect(() => {
    setCurrPosition({lat: latitude, long: longitude})
  }, [latitude, longitude]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions