//data from Firebase
[
{
"Role": "Student",
"Section": "A",
"StudentEmail": "amir@gmail.com",
"StudentFather": "Atif Mian",
"StudentID": "Bs-2000",
"StudentName": "Amir Liaqat",
"Subject": ["Web", "app"],
"uid": "atwYEXNseKYyXfnTpldcTyL2Hj83"
}
]
I want to get only "Subject": ["Web", "app"] in the form of list
I used the code below but I think it was wrong
{subject
? subject.map((a, i) => {
return <Text key={i}>{a}</Text>
})
: <></>
}
I received result "WebApp" but I need in the form of list.
I receive the data from there
const [subject, setSubject] = useState();
firestore()
.collection('users')
.where('uid', '==', StudentUID)
.onSnapshot({
error: e => console.error(e),
next: querySnapshot => {
var data = [];
var sub = [];
querySnapshot.forEach(doc => {
data.push(doc.data());
sub.push(doc.data().Subject);
});
setStudents(data);
setSubject(sub)
console.log(sub)
},
});