I have a component that renders tags. It loops through a Map and displays the data. I tryed using forEach but it doesn't work. However it works if I convert the map to an array (foreach doesn't work on the array either). What am I missing here?
This works:
render(){
return(
<div class="container">
{Array.from(this.props.tags.values()).map((tag,i) => (
<Tag
handleKeyDown={this.handleKeyDown.bind(this)}
handleBlur={this.handleBlur.bind(this)}
handleTouchTap={this.handleTouchTap.bind(this)}
handleRequestDelete={this.handleRequestDelete.bind(this)}
tag={tag}
key={i}
/>
))}
</div>
)
}
This doesn't:
render(){
return(
<div class="container">
{this.props.tags.forEach((tag,i) => (
<Tag
handleKeyDown={this.handleKeyDown.bind(this)}
handleBlur={this.handleBlur.bind(this)}
handleTouchTap={this.handleTouchTap.bind(this)}
handleRequestDelete={this.handleRequestDelete.bind(this)}
tag={tag}
key={i}
/>
))}
</div>
)
}