@wojtekmaj/react-hooks
Version:
A collection of React Hooks.
11 lines (10 loc) • 531 B
TypeScript
/**
* Returns current position from Geolocation API.
*
* @param {PositionOptions} [options] Options to pass to Geolocation.getCurrentPosition
* and Geolocation.watchPosition.
* See https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions. WARNING! If you define
* the function in component body, make sure to memoize it.
* @returns {GeolocationCoordinates} Object with latitude and longitude
*/
export default function useCurrentPosition(options?: PositionOptions | undefined): GeolocationCoordinates | null;