i have an array that i am trying to read and store in a state however, with the code below, here is the error i get: "function collectionReferenace.doc() requires its first argument to be of type non-empty string, but it was undefined" any idea why this is happening and what is the solution?
componentDidMount(){
dbh.collection('Groups').doc(this.props.route.params.groupName)
.collection('Enrolled').doc('ids').get()
.then(querySnapshot => {
querySnapshot(doc => {
this.setState({
playerIDs: doc.data().players
})
})
})
console.log(this.state.playerIDs)
}
the this.props.route.params.groupName is passed from the navigation of the previous screen. When I set a constant in the render function to it and call that variable it works fine.
render() {
const groupName = this.props.route.params.groupTitle
return
<Text>{groupName}</Text>
for your reference, here is how i am getting that route.param
<GroupComponent onPress = {
() => this.props.navigation.navigate
('Attendance', {groupTitle: group.GroupName, groupID: group.id})
} />
this.props.route.params.groupNameis null (or undefined). Print out value ofthis.props.route.params.groupNamejust to check and tell me what it is. It will be undefined, what do you expect it to be and how do you get the value?this.props.route.params.groupNameis null. So how do you get that value and what do you expect it to be? Add the code to the question.this.props.route.params.groupName) to your question, so I can see what's making it undefined please. Also try hard coding a value into.doc(this.props.route.params.groupName)and see if you get is what's expected.