Hook for watching the users current location as geo coordinates.
✓ Published0🌍 Public
Aabonello
Last edited Jul 27, 2021
Created on Dec 30, 2021
This example demonstrates a React hook that continuously tracks the user's current geographic coordinates using the browser's Geolocation API. It shows the live position data and any associated error state returned from the device. The hook leverages `navigator.geolocation.watchPosition` to subscribe to location updates, storing results via `useState` and cleaning up with `clearWatch` on unmount. It accepts optional `PositionOptions` to configure accuracy, timeout, and maximum age, making the location stream configurable and reactive within any React component.
AI-generated description