I am getting the following error:
Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
I am using context in react and having a problem with props as I have forEach
loop in inner components to fetch data from the database.
I don't know how to render a collection by using an array here.
Here is the code to fetch data due to which the error is occurring:
import React, { useEffect, useState } from "react";
import { db } from "../services/firebase";
import style from "./css/dashboard.module.css";
import InputTask from "./InputTask";
import Task from "./Task";
const Tasks = ({ user }) => {
console.log("Tasks");
return (
<>
<div className={style.card}>
<InputTask user={user} />
</div>
{true
? db
.collection("Users")
.doc(`${user.email}`)
.collection("tasks")
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log(doc.id, " => ", doc.data());
return (
<div className={style.card}>
<Task todo={doc} />
</div>
);
});
})
: null}
</>
);
};
export default Tasks;
Error's snapshot attached here