Vielen Dank im Vorausreagieren nativen Zugriff Variable außerhalb componentDidMount fuction
I currentPostion aus getCurrentPosition Funktion zugreifen müssen in reagieren nativer und ich Anfänger bin in nativer reagieren.
Code:
constructor(props) {
super(props)
this.state = {
coords: [],
currentPostion: ""
}
}
componentDidMount() {
navigator.geolocation.getCurrentPosition(
(position) => {
var initialPosition = JSON.stringify(position);
this.setState({'currentPostion':initialPosition});
},
(error) => alert(error.message),
{enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
);
alert(JSON.stringify(this.state));
}
Help Me !!!