Skip to content

Commit

Permalink
chore(docs): Add useGeolocation documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldon-welinga committed Mar 20, 2022
1 parent 5c3fff1 commit 5d1ddcb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ yarn add react-modern-hooks
- [`useFetch`](./docs/useFetch.md) - Hook for fetching/refetching data from an API endpoint
- [`useNetwork`](./docs/useNetwork.md) - Hook for getting the network status
- [`useFullScreen`](./docs/useFullScreen.md) - Hook to toggle a given HTMLElement to fullscreen and exit fullscreen
- `useGeolocation` - Hook to get a users current geographic location
- [`useGeolocation`](./docs/useGeolocation.md) - Hook to get a users current geographic location
- `useSelectedText` - Hook to get the highlighted text on a page
- `useCopyToClipboad` - Hook to copy text to clipboad
- `useStateCallback` - Hook that acts as a state callback i.e. functionality same as react class-based setState that provides a fallback with your current set state
Expand Down Expand Up @@ -77,7 +77,7 @@ import { useFullScreen } from 'react-modern-hooks';

const App = () => {
const ref = useRef(null);
const { fullScreen, open, close, toggle, error } = useFullScreen();
const { fullScreen, open, close, toggle, error } = useFullScreen(ref);

return (
<div>
Expand All @@ -90,3 +90,18 @@ const App = () => {
);
};
```

### useGeolocation

Hook to get a users current geographic location

```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>;
};
```
2 changes: 1 addition & 1 deletion docs/useFullScreen.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useFullScreen } from 'react-modern-hooks';

const App = () => {
const ref = useRef(null);
const { fullScreen, open, close, toggle, error } = useFullScreen();
const { fullScreen, open, close, toggle, error } = useFullScreen(ref);

return (
<div>
Expand Down
30 changes: 30 additions & 0 deletions docs/useGeolocation.md
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

0 comments on commit 5d1ddcb

Please sign in to comment.