Closed. This question needs
My code:
useEffect(() => {
db.collection('users').get()
.then(snapshot => {
snapshot.forEach(doc => {
const appointment = doc.data();
console.log(appointment);
});
});
}, []);
CodePudding user response:
You can create a new array and populate it with all the new objects and use .push
to insert the current value at the end of the array each interation.
const newArray = [];
newArray.push(appointment);
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
CodePudding user response:
You could use a state to store that and render later on:
const [appointment, setAppointment] = useState([]);
useEffect(() => {
db.collection("user")
.get()
.then((snapshot) => {
const _appointment = snapshot.map((doc) => doc.data());
setAppointment(_appointment);
});
});