I have an object that looks like this:
{
"startups" : {
"startup0":{
"achievements" : "Is done!",
"how_build" : "In python and using google visio api",
"inspiration" : "All the hot dogs in the world",
"proyect_name" : "Hog dog or not Hot dog",
"team" : {
"Steven Anderson" : {
"area" : "CEO",
"email" : "[email protected]",
"expertise" : "full-stack engineer"
}
},
"what_does" : "Say is the image is a hot dog or not"
},
"startup1":{
"achievements" : "Is done!",
"how_build" : "In python and using google visio api",
"inspiration" : "All the hot dogs in the world",
"proyect_name" : "Big Brother",
"team" : {
"Steven Anderson" : {
"area" : "CEO",
"email" : "[email protected]",
"expertise" : "full-stack engineer"
}
},
"what_does" : "Say is the image is a hot dog or not"
}
}
}
I initialize my state in this form:
this.state={
startups:[]
Here I call to firebase to set my state:
componentDidMount(){
const rootRef = firebase.database().ref().child('startups')
rootRef.once('value', snap =>{
this.setState({
startups: this.state.startups.push(snap.val())
});
}
);
} I have tried looping in different ways: 1.
formatStartUps(){
const startups = [this.state.startups];
startups.forEach((element)=>{console.log(element)} )
}
2.
formatStartUps(){
const startups = [this.state.startups];
startups.map((startup,index)=>{<p key={index}>{startup}</p>))
}
3.
formatStartUps(){
const startups = [this.state.startups];
for(let startup of startups){
console.log(startup)
}
}
And then I call to the fire-base database to set my state and works, but I can't loop to each startup to render these values in my div.
How can I loop this object and render each value in my render() method?
I appreciate the help