I have the following object:
Now when I try to loop through it:
{Object.keys(this.state.extras).forEach(key => (
<div style={{'margin-top': '15px'}}>
<Addon data={this.state.extras[key]} addonTitle={key} type={key}
selectCallback={this.callbackSelectItem}
unSelectCallback={this.callbackUnSelectItem}/>
</div>
))}
No html is displayed.
I have also tried:
let extra;
Object.keys(this.state.extras).forEach(key => {
extra += (<div style={{'margin-top': '15px'}}>
<Addon data={this.state.extras[key]} addonTitle={key} type={key}
selectCallback={this.callbackSelectItem}
unSelectCallback={this.callbackUnSelectItem}/>
</div>);
});
However this returns "[object Object][object Object]"
What have I done wrong?
Update
The object key is extras when I set it on the state.

extraand notextras? It also seems to be an array, not an objectextrais not an object its an array. And extra[0] is anobejct