I am loading in picker items from an arraylist that gets it's data from an firebase subscriber function.
<Picker
selectedValue={this.state.projectName}
onValueChange={(itemValue) => this.temptemp(itemValue)}
style={styles.picker}>
{this.state.projectList.map(project =>
<Picker.Item label={project.data().name} value={project.id} />)}
</Picker>
In my constructor:
this.subscriber = firebase.firestore().collection('users').doc(auth.currentUser.uid).onSnapshot(doc => {
this.setState({projects: doc.data().projects})
this.getProjectNames();
})
Once I add an item from the picker to my firestore I do not want it to show up in my picker anymore. So, the subscriber function retrieves the projects that should be displayed again. However, once this happens the onValueChange is not called again. Which results in old projects (that are no longer displayed) being added again.
How can i retrieve data from the picker when dynamically loading its picker items?