export function ListData() {
const [dataList,setDataList] = useState([]);
useEffect(() =>{
async function callData(){
const result = await GetAllDataOnce()
return result
}
setDataList(callData())
},[])
async function GetAllDataOnce() {
const querySnapshot = await getDocs(collection(db, "repos"));
var data = [];
querySnapshot.forEach(doc => {
data.push({
id: doc.id,
data: doc.data()
})
})
return data;
}
return (
<table>
{dataList.map(returndata => (
<tr key={returndata.id}>
<td>{returndata.data}</td>
</tr>
))}
</table>
)}
Here is the data I am working with:
This is using react with firebase firestore. I want to display each name with their respective desc, icon, and repo. I am getting error
table.js:37 Uncaught TypeError: dataList.map is not a function
I think you could try to debug by printing value from the function callData, then check if it is an array.
async function callData(){
const result = await GetAllDataOnce()
console.log(result)
console.log(typeof result)
return result
}