0
我的代码有,在React.createClass()调用:如何初始化React Native for iOS下的低精度地理位置?
watchID: (null: ?number),
componentDidMount: function() {
navigator.geolocation.getCurrentPosition(
(initialPosition) => this.setState({initialPosition}),
(error) => console.error(error),
(position) => this.setState({position}),
{enableHighAccuracy: false, timeout: 20000, maximumAge: 60 * 60 * 1000});
this.watchID = navigator.geolocation.watchPosition((lastPosition) =>
this.setState({lastPosition}));
},
这是产生错误消息Argument 0 (RCTLocationOptions of RCTLocationObserver.getCurrentPosition must not be null
。
初始位置箭头函数有问题吗?另外,如何用一个合适的匿名函数替换initialPosition参数,该函数将初始位置设置为初始位置和最后位置(既是初始位置又是最后位置),并调用一个this.fetchData()
?
(随意解释什么,我缺少有关箭头功能...)
感谢,
看起来你没有按照正确的顺序传递参数?我不熟悉反原生:https://github.com/facebook/react-native/blob/master/Libraries/Geolocation/RCTLocationObserver.m#L194-L196 –