项目
在 GitHub 查看 enableHighAccuracy
timeout
maximumAge
render
lazy
onSuccess
onError
tkh44/react-geolocation
关于
🌎🛰 面向 React 的声明式地理定位。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文react-geolocation
🌎🛰 Declarative geolocation in React
Install
npm install -S react-geolocation
Basic Usage
<Geolocation
render={({
fetchingPosition,
position: { coords: { latitude, longitude } = {} } = {},
error,
getCurrentPosition
}) =>
<div>
<button onClick={getCurrentPosition}>Get Position</button>
{error &&
<div>
{error.message}
</div>}
<pre>
latitude: {latitude}
longitude: {longitude}
</pre>
</div>}
/>
Props
enableHighAccuracy boolean
timeout number
maximumAge number
render function
render is a function that receives an object as its only argument.
The object contains the following keys:
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.
<Geolocation
lazy
render={({getCurrentPosition, fetchingPosition}) => (
<div>
<button onClick={getCurrentPosition}>Get Current Position</button>
<div>Fetching Position: {fetchingPosition}</div>
</div>
)}
/>
// renders "Fetching Position: false" until the button is clicked
onSuccess function
callback called on success. Its only argument is position
onError function
callback called on error. Its only argument is error
探索相关项目
加载中…