1.1.0 • Published 1 year ago

use-geolocation-api v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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.

License

MIT