Кто-нибудь может объяснить, что я делаю не так, моя консоль setState возвращает неопределенное значение, когда первая консоль возвращает правильные значения
return firebase.database().ref('Users/Trainers/').on('value', (snapshot) => {
snapshot.forEach(function(childSnapshot){
// var childKey= childSnapshot.key;
var childData= childSnapshot.val();
var childEmail = childData.email;
var childfirstName = childData.firstName;
var childlastName = childData.lastName;
var childTrainers = childfirstName + ' ' + childlastName + ' ' + childEmail;
console.log(childTrainers);
})
this.setState({
Trainers: snapshot.val().childTrainers
})
console.log(this.state.Trainers)
})