I fetch data from Firebase and then push that data to array with components. I am trying to display that by using the following code but React displays nothing, also there are no errors in console and during compiling.
import React, { useState ,useEffect } from "react";
import './App.css';
import db from "./firebase";
import { doc, getDocs, getDoc, collection, query, orderBy, limit, where } from "firebase/firestore";
function App() {
useEffect(() => {
getdata();
}, []);
const names = []
async function getdata() {
getDocs(collection(db,'questions')).then((snapshot) => {
snapshot.forEach(doc => {
names.push(<p className="question" >{doc.id}</p>)
Object.values(doc.data()).forEach( test => {
names.push(<p className="answer" >{test}</p>)
});
});
})
}
return (
<div className="App">
{names}
</div>
)
}
export default App;