I have a function where I get data from Firestore, I would like to show the data from the function in a SectionList in React Native. This is my code:
The query:
function EntryDate() {
firebase
.firestore()
.collection("journal")
.doc(currentUserUID)
.collection("entry")
.get()
.then((querySnapshot) => {
querySnapshot.forEach((entry) => {
const { title, createdAt, getMonth, getDay, sortTime } = entry.data();
});
});
}
The variable where I pass the function:
const DATA = [
{
title: EntryDate(),
data: todos,
},
];
and where I want the data to return:
<SectionList
style={{ marginLeft: 15 }}
sections={DATA}
keyExtractor={(item) => item.id}
renderItem={({ item }) => <TextLog {...item} />}
renderSectionHeader={({ section: { title } }) => <Text>{title}</Text>}
/>