@supunlakmal/hooks
Version:
A collection of reusable React hooks
22 lines (21 loc) • 799 B
TypeScript
export interface GeolocationState {
loading: boolean;
accuracy: number | null;
altitude: number | null;
altitudeAccuracy: number | null;
heading: number | null;
latitude: number | null;
longitude: number | null;
speed: number | null;
timestamp: number | null;
error: GeolocationPositionError | Error | null;
}
export interface UseGeolocationOptions extends PositionOptions {
}
/**
* Custom hook to track the user's geolocation.
*
* @param {UseGeolocationOptions} [options] - Optional configuration for the geolocation request (e.g., enableHighAccuracy).
* @returns {GeolocationState} An object containing the geolocation data, loading state, and error state.
*/
export declare const useGeolocation: (options?: UseGeolocationOptions) => GeolocationState;