Here is my code
const FindFun = () =>{
const [place, setPlace] = useState('');
var arr = [];
function _handlePress(){
firebase.firestore().collection('something').where("text", "==" ,
place.place).get().then((querySnapshot) =>{
querySnapshot.forEach((doc) =>{
arr.push(doc.data());
})
})
}
return(
<View>
<Text>Insert the place</Text>
<TextInput style={styles.place}
editable
maxLength = {100}
placeholder = "E.g. New York"
onChangeText={(text) => setPlace({place:text})}
/>
<Button
title = 'Search'
onPress={() => _handlePress()}
/>
{arr.map((item, key)=>(
<Text key={key}> { item.user } </Text>)
)}
</View>
)
}
Disclaimer
I am pretty new to React and React Native, so I am not entirely sure if the way I am doing is correct.
The Problem
Currently in my last <Text> component I am not getting any data to display.
Facts
The arr seems to be populated correctly with the DB results that I queried.
The Result
What I would like to have is a dynamic population of <Text> components with the appropriate data as soon as the query is completed. The ideas behind this is that the user clicks the button, the program gathers the data from the DB and then that data is displayed on the screen.
Any advise is greatly appreciated.