UNPKG

beautiful-react-hooks

Version:

A collection of beautiful (and hopefully useful) React hooks to speed-up your components and hooks development

25 lines (24 loc) 1.21 kB
import { SomeCallback, BRHGeolocationPosition, BRHGeolocationPositionError } from './shared/types'; export declare type GeolocationState = { readonly isSupported: boolean; readonly isRetrieving: boolean; readonly position: BRHGeolocationPosition; }; /** * Returns a frozen object containing the `position` object, the `isSupported` boolean flag, reporting whether the * geolocation API is supported or not and the `isRetrieving` boolean flag reporting whether the hook is fetching the * current position. * The position is retrieved by using the * [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API/Using_the_Geolocation_API), * when supported.<br/><br /> * It possibly accepts an object of [geolocation options] * (https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions) to be used as parameter when using the * `Geolocation.getCurrentPosition()` method. */ declare const useGeolocationState: (options?: PositionOptions) => Readonly<{ onError: (callback: SomeCallback<BRHGeolocationPositionError, void>) => void; isSupported: true; isRetrieving: boolean; position: BRHGeolocationPosition; }>; export default useGeolocationState;