Issue: After it enters the firebase listener, the code works until this.state.users
appears, where it stops working.
This part of code is located somewhere into a button but there is no problem with it.
this.setState({
users:
[
{
name: Object.values(snapshot.val())[i].name,
email: Object.entries(snapshot.val())[i][0]
}
],
found:true
})
Additional information:
constructor() {
super();
this.state = {
searchInput: '',
foundUsersOutput:null,
users:[], <---
found:false, <---
}
this.findUser = this.findUser.bind(this)
}
This is where the problem is located, from here the error starts. The error refers to console.log(this.state.users+'2')
componentDidUpdate(){
console.log(this.state.users+'0')
console.log('here0')
if(this.state.found === true){
console.log(this.state.users+"1")
database().ref('users').child(this.state.users[0].email).on('child_added', function(data){
console.log('asd')
console.log(this.state.users+'2')
})
}
}
Output:
[object Object]0
here0
[object Object]1
asd
Error: error part 1 error part 2