Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tkh44/react-geolocation
🌎🛰 Declarative geolocation for React
https://github.com/tkh44/react-geolocation
declarative geolocation react
Last synced: 13 days ago
JSON representation
🌎🛰 Declarative geolocation for React
- Host: GitHub
- URL: https://github.com/tkh44/react-geolocation
- Owner: tkh44
- License: mit
- Created: 2017-08-13T06:22:14.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-17T22:50:38.000Z (almost 6 years ago)
- Last Synced: 2024-10-14T07:50:02.574Z (25 days ago)
- Topics: declarative, geolocation, react
- Language: JavaScript
- Homepage: https://tkh44.github.io/react-geolocation/
- Size: 26.4 KB
- Stars: 241
- Watchers: 6
- Forks: 25
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-render-props - react-geolocation
- awesome-react-render-props - react-geolocation
README
# react-geolocation
🌎🛰 Declarative geolocation in React[![npm version](https://badge.fury.io/js/react-geolocation.svg)](https://badge.fury.io/js/react-geolocation)
[![Build Status](https://travis-ci.org/tkh44/react-geolocation.svg?branch=master)](https://travis-ci.org/tkh44/react-geolocation)
[![codecov](https://codecov.io/gh/tkh44/react-geolocation/branch/master/graph/badge.svg)](https://codecov.io/gh/tkh44/react-geolocation)- [Install](#install)
- [Basic Usage](#basic-usage)
- [Props](#props)## Install
```bash
npm install -S react-geolocation
```## Basic Usage
```javascript
}
Get Position
{error &&
}
{error.message}
latitude: {latitude}
longitude: {longitude}
/>
```## Props
### [enableHighAccuracy `boolean`](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions/enableHighAccuracy)
### [timeout `number`](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions/timeout)
### [maximumAge `number`](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions/maximumAge)
### render `function`
`render` is a function that receives an object as its only argument.
The object contains the following keys:
- fetchingPosition: `bool`
- [position](https://developer.mozilla.org/en-US/docs/Web/API/Position): `object`
- [error](https://developer.mozilla.org/en-US/docs/Web/API/PositionError): `object`
- getCurrentPosition: `function`### lazy `boolean`
If true then the component will **not** perform the fetch on mount.
You must use the `getCurrentPosition` named argument in order to initiate the request.```javascript
(
Get Current Position
Fetching Position: {fetchingPosition}
)}
/>
// renders "Fetching Position: false" until the button is clicked
```### onSuccess `function`
callback called on success. Its only argument is `position`
- https://developer.mozilla.org/en-US/docs/Web/API/Position
### onError `function`
callback called on error. Its only argument is `error`
- https://developer.mozilla.org/en-US/docs/Web/API/PositionError