use-geolocation-api
v1.1.0
Published
No dependencies, just Closure and Geolocation. ( Native API )
Downloads
21
Maintainers
Readme
use-geolocation-api
No dependencies, just Closure and Geolocation. ( Native API )
Installation
Using npm
npm install use-geolocation-api
using yarn
yarn add use-geolocation-api
Usage
import React from 'react'
import useGeolocation from 'use-geolocation-api'
export function Home() {
const { requestGeolocation, data, loading } = useGeolocation()
React.useEffect(() => {
requestGeolocation()
}, [])
}
Properties
Closure
onSuccess?: (data: GeolocationPosition) => void
onError?: (error: GeolocationPositionError) => void
getCurrentPositionOptions?: PositionOptions
Return
data: GeolocationPosition | null
error: GeolocationPositionError | null
loading: boolean
isError: boolean
isMounted: boolean
requestGeolocation: () => void
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.