Description
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: v8.2.1
Yarn: NO
npm: 5.5.1
Watchman: 4.9.0
Xcode: Version 8.3.3 (8E3004b)
Android Studio: NO
Packages: (wanted => installed)
react-native: 0.25.1
react: ^0.14.9
Target Platform: iOS (10.3)
Steps to Reproduce
(Write your steps here:)
componentDidMount() { //Alert.alert('xx',this.state.user.FName+' ') this.watchID = navigator.geolocation.watchPosition((position) => { var lastPosition = JSON.stringify(position); this.setState({ lastPosition }); }); console.log('this.watchID') console.log(this.watchID) }
**componentWillUnmount() { // here is the bug** navigator.geolocation.clearWatch(this.watchID); }
-
when unmount , appear this error
_reactNative.DeviceEventEmitter.removeListener is not a function
Expected Behavior
I don't want upgrade RN to other version,because it will occur lots of error,that's too bad!
(Write what you thought would happen.)
I do catch error,but can't catch the error
componentWillUnmount() {
try {
navigator.geolocation.clearWatch(this.watchID);
debugger;
} catch (error) {
console.log(error)
}
// debugger;
}
(Write what happened. Add screenshots!)
Reproducible Demo
(Paste the link to an example project and exact instructions to reproduce the issue.)