A react geolocation hook
npm install react-navigator-geolocationA react geolocationing hook
Yarn
``console`
$ yarn add react-navigator-geolocation
Npm
`console`
$ npm install react-navigator-geolocation

Simple syntax
`TSX
import React from "react";
import useGeolocation from "react-navigator-geolocation";
const App: React.FC = () => {
const { isEnabled, coords } = useGeolocation();
return isEnabled ? (
export default App;
`

Suppressed on mountage
`TSX
import React from "react";
import useGeolocation from "react-navigator-geolocation";
const App: React.FC = () => {
const { isAvailable, isEnabled, coords, suppressRequest } = useGeolocation({ suppressOnMount: true });
return isAvailable ? (
isEnabled ? (
export default App;
`
| Param | Type | Default | Definition |
| :-------------- | :-----: | :-----: | :--------- |
| suppressOnMount | boolean | false | Suppress request on mountage |{ enableHighAccuracy: true, timeout: 5000, maximumAge: 0 }
| positionOptions | object | | Read more |false` | When enable it returns periodically (by movement) coordinates |
| watchMode | boolean |
> useGeolocation({ suppressOnMount: false, positionOptions: { enableHighAccuracy: true, timeout: 5000, maximumAge: 0 }, watchMode: false })
| Variable | Type | Definition |
| :------: | :--: | :--------- |
| isAvailable | boolean | Browser does support Geolocation API |
| isSupressed | boolean | If request was suppressed |
| isEnabled | boolean | If location is granted or denied |
| isExpired | boolean | If request is timed out |
| coords | object | Read more
| suppressRequest | method | It receives a boolean as value |
| watchId | number | If watchMode is enabled you'll get the id of watching
> const { isAvailable, isSupressed, isEnabled, isExpired, coords, suppressRequest, watchId } = useGeolocation(...)