I'm fetching data from firestore ( an array of items ) which is asynchronous, and when I console log it everything is fine ( it displays array that I'm requesting ), but when I try to render it in React Component using Array.map nothing displays.
import React, {useEffect} from 'react';
const Likes = props =>{
const likedPosts = []
useEffect(() => {
db.collection('postLikes')
.where('postID', '==', props.uid)
.get()
.then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
likedPosts.push(doc.data())
})
})
}, [])
return(
<div>
{likedPosts.map(post =>{
return(
<h1>{post.whoLiked}</h1>
)
})}
</div>
)
}
And after that it displays nothing for some reason. I tried literally everything. I'm stuck on this for 3 hours
useState.