class MyComponent extends Component {
constructor() {
super();
this.state = {};
}
componentDidMount() {
this.watcher = navigator.geolocation.watchPosition(
pos => this.setState(pos.coords);
);
}
componentWillUnmount() {
navigator.geolocation.clearWatch(this.watcher);
}
render() {
return (
<Text>{this.state.latitude}</Text>
);
}
}
@facebook-github-bot label Icebox
Hi there! This issue is being closed because it has been inactive for a while.
But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/geolocationwatchposition-subscriptionlistenerapply-is-not-a-function
ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub.
Also, if this issue is a bug, please consider sending a PR with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.
@facebook-github-bot close
@charpeni tells me to close this issue. If you think it should still be opened let us know why.
For people encountering this later... I ran into this as well because I passed a position options object without an error handler. If you do so, the eventEmitter will try to run your options object as the error handler function. Also, this means that your options aren't being processed properly without an error handler, so if you need to send options to watchPosition, make sure to send the semi-optional error handler as well.
Most helpful comment
For people encountering this later... I ran into this as well because I passed a position options object without an error handler. If you do so, the eventEmitter will try to run your options object as the error handler function. Also, this means that your options aren't being processed properly without an error handler, so if you need to send options to watchPosition, make sure to send the semi-optional error handler as well.