use-geolocation-api
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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

Package Sidebar

Install

npm i use-geolocation-api

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

12.6 kB

Total Files

13

Last publish

Collaborators

  • alexcastrodev