-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): Add useGeolocation documentation
- Loading branch information
1 parent
5c3fff1
commit 5d1ddcb
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# useGeolocation | ||
|
||
Hook to get a users current geographic location | ||
|
||
## Usage | ||
|
||
```jsx | ||
import { useGeolocation } from 'react-modern-hooks'; | ||
|
||
const App = () => { | ||
const ref = useRef(null); | ||
const { longitude, latitude, location, userIP, country, city, region, error, loading } = useGeolocation(); | ||
|
||
return <div>Current city: {city}</div>; | ||
}; | ||
``` | ||
|
||
## References | ||
|
||
### Output Variables | ||
|
||
`location` - Location object with all users details <br/> | ||
`latitude` - Users latitude position<br/> | ||
`longitude` - Users longitude position<br/> | ||
`userIP` - Users IP address<br/> | ||
`city` - City the user is currently located<br/> | ||
`region` - Region the user is currently located<br/> | ||
`country` - Country the user is currently located<br/> | ||
`error` - Error occured during geolocating a users<br/> | ||
`loading` - Loading state when users location is still being fetched |