react-use
Version:
Collection of React Hooks
27 lines (26 loc) • 941 B
TypeScript
/**
* @desc Made compatible with {GeolocationPositionError} and {PositionError} cause
* PositionError been renamed to GeolocationPositionError in typescript 4.1.x and making
* own compatible interface is most easiest way to avoid errors.
*/
export interface IGeolocationPositionError {
readonly code: number;
readonly message: string;
readonly PERMISSION_DENIED: number;
readonly POSITION_UNAVAILABLE: number;
readonly TIMEOUT: number;
}
export interface GeoLocationSensorState {
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?: Error | IGeolocationPositionError;
}
declare const useGeolocation: (options?: PositionOptions | undefined) => GeoLocationSensorState;
export default useGeolocation;