Hi i am trying to get the data from my database, in componentDidMount(), it works fine with this :
componentDidMount() {
firebase.database().ref('/users/' + user.uid).once('value').then(function(snapshot) {
var valeur = snapshot.val();
return valeur;
});
this.setState({userData:valeur});
}
I just want to know how can i assign this data to a variable that can be use outside of this function, i tried setstate and using variable that i declare outside nothing work i get :react native possible unhandled promise rejection (id 0) Typeerror: this.setState is not a function. Thank you