retrieveData = async () => {
try {
//Retrieving values from AsyncStorage
let voiture = await AsyncStorage.getItem('VOITURE')
this.state.DBCarName=[];
this.state.DBCarName = JSON.parse(voiture);
alert(this.state.DBCarName)
}
catch {
alert('error')
}
}
The call of the function :
render() {
this.retrieveData();
I want to use my retrieve function in order to assign a value to the DBCarName state in order to render it in a Text component. The thing is, when calling the function in the render method, it returns null, which probably means that my function didn't execute and my array state is empty.
Any idea on how to deal with this?