So Im trying to save an address that I get with async storage and then reading it on another page. The problem is that every time i save a new address by overiding the last address, the newest one doesnt get displayed only the one before the newest one. I get address and save it with following
getReverseGeoLocationUri(lat: number, lng: number): string {//** Init */Geocoder.init("here")let apiKey = its herelet uri: string = `https://maps.googleapis.com/maps/api/geocode/json?key=${apiKey}&latlng=${lat},${lng}&sensor=false`;//** Return result */var addressComponent: stringGeocoder.from(lat, lng) .then(async json => { var addressComponent = json.results[0].formatted_address; this.setState({ address: addressComponent.split(',') }) AsyncStorage.setItem('address', JSON.stringify(this.state.address)) console.log(addressComponent) return addressComponent; }) .catch(error => console.warn(error));return addressComponent;}
I still get values so I know its working I just dont understand why I dont get the newest one. Am I not overiding the variable correctly.