state = {AnswerQuery : '', answerdetail: []};
getData() {
const data = this.props.navigation.getParam('data');
this.setState({
data
});
}
renderdata(){
console.log(this.state.data) // not able to recieve data here
const {answerdetail} = this.state
firebase.firestore().collection("queries").doc(this.state.data).collection("answers").onSnapshot((answerSnapShot) => {
console.log(this.state.data) // recieving data here
answerSnapShot.forEach((doc) => {
answerdetail.push(doc.data())
console.log(doc.data())
})
console.log(this.state.data) // recieving data here
this.setState(answerdetail)
// console.log(answerdetail)
//console.log(anotherentity)
})
}
componentDidMount(){
this.getData()
this.renderdata()
}
Receiving value from another screen using getData() function, but not able to use that value inside renderdata() function while passing the data into firebase firestore command, but i am able to access that data inside the firebase firestore command.
this.state.data has no value while passing it in "doc" firebase firestore function doc(this.state.data)
Please help