Install
npm
Description
TheuseGeoLocation
hook provides a simple way to retrieve the user’s current geographic location. This is useful for applications that need to display or use location-based data, such as maps, weather information, or location-based services. The hook handles the process of fetching the location and provides both the location data and any potential errors.
Parameters
This hook does not require any parameters.Return Values:
Name | Type | Description |
---|---|---|
location | object | The location object containing geographic coordinates (latitude and longitude ) and other metadata. |
error | object | An error object if there was an issue retrieving the location, or null if no errors occurred. |
Example
useGeoLocation.example.tsx