UNPKG

web-api-hooks

Version:

Essential set of React Hooks for convenient Web API consumption.

18 lines (17 loc) 584 B
/** * Tracks geolocation of the device. * * @param options Additional watching options. * @param errorCallback Method to execute in case of an error, e.g. when the user denies location sharing permissions. * @returns Locational data, or `undefined` when unavailable. * * @example * function Component() { * const geolocation = useGeolocation(); * if (geolocation) { * const { coords } = geolocation; * } * // ... * } */ export default function useGeolocation(options?: PositionOptions, errorCallback?: (error: PositionError) => void): Position | undefined;