I want to collect the UIDs to the Array fields in Firestore. Successfully fetched each user data, however, I can't list.
contactArray: {"0": "xxxxxxxxxxxx", "1": "yyyyyyyyyyyy"}
User data can be retrieved, but the problem cannot be displayed as a list. I could push it, but it disappears for some reason.
The warning:
Expected to return a value in arrow function
useEffect
const [contactList, setContactList] = useState([])
useEffect(() => {
if (currentUserUid) {
firestore.doc(`users/${currentUserUid}`).get().then(userSnapshot => {
const { contactUidList } = userSnapshot.data()
return contactUidList
})
.then((contactUidList) => {
contactUidList.map((contactUid) => {
firestore.doc(`users/${contactUid}`)
.onSnapshot(userQuerySnapshot => {
contactList.push(userQuerySnapshot.data())
setContactList(contactList)
})
})
})
}
}, [currentUserUid, contactList])
View
return (
<ul>
{contactList.map((contact, idx) => {
return(<p>{contact.name}</p>)
))
)