I am trying to render a list of products from my firestore database. I am able to get the items but not display them. How can you display data from firebase in react?
This is the error message my console log shows:
react-dom.development.js:13231 Uncaught Error: Objects are not valid as a React child (found: object with keys {Description, Name, Quantity}). If you meant to render a collection of children, use an array instead.
import Firebase from "../FireBase";
import { useEffect, useState } from "react";
const TechP= () => {
const [techList, setTechList] = useState([]);
const getTech = async () => {
try {
const list = [];
var snapshot = await Firebase.firestore().collection("Tech").get();
snapshot.forEach((doc) => {
list.push(doc.data());
});
setTechList([...list]);
console.log(list);
} catch (e) {
alert('error');
}
};
//Call when component is rendered
useEffect(() => {
getTech();
}, []);
return (
<div>
<p>working</p>
<form>here{techList}</form>
</div>
)
}
export default TechP;