I'm trying to get my project from firebase and put it in an array with hooks.
One project look like : {name: "movie app", date: t, description: "this is my first app, a complete movie app"}
//hooks
const [projects, setProject] = useState([]);
//function for get projects
async function getprojects(){
let finalProjects = [];
await db.collection('projects').get().then((querySnapshot) => {
querySnapshot.docs.map(res => {
const a = res.data();
finalProjects.push(a)
})
//error here
setProjects(finalProjects)
})
}
useEffect(() => {
getprojects();
}, []);
But finalProjects.push(res.data()) doesn't work because "Argument of type 'DocumentData' is not assignable to parameter of type 'never'." But how I'm suppose to put all my project into projects with setProjects