I Have Code Like this Model.js
import firebase from '../config/Firebase'
class Dashboard {
GetAllBlog() {
return firebase.collection('blogs').get()
}
}
export default new Dashboard()
then, I return model to home.js
import React from 'react';
import Index from './components/index'
import CardOverview from './components/CardOverview'
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Container from '@material-ui/core/Container'
import Paper from '@material-ui/core/Paper'
import Grid from '@material-ui/core/Grid'
import Typography from '@material-ui/core/Typography';
import DashboardService from '../services/dashboard'
const styles = theme => ({
root: {
padding: theme.spacing(3, 2),
},
row: {
padding: theme.spacing(3, 2),
}
});
class Home extends React.Component {
state = {
blogs: []
}
componentDidMount() {
DashboardService.GetAllBlog()
.then(snapshot => {
this.setState({
blogs: snapshot
})
})
.catch(err => {
console.log('Error getting documents', err);
});
}
render() {
const { classes } = this.props
const {
blogs
} = this.state
blogs.forEach(element => {
console.log("blogs", element.data().title)
});
return (
.......
but I Got Double when using foreach like this
Actually, I have data like this(Two data)
I Look how to make it simple with Convert All snapshot to Array,(I can create joined array from firebase), but I confused, Why this double loop, but it loop 2 times, but in one time, its loop based by length

