Trying to keep it simple here.
I have some data. It contains a list of objects we'll call items. I loop through the items, and pass various properties to a component like so:
render: function(){
var itemList = [];
items.forEach(function(item){
itemList.push(<Component name={item.name} tags={item.tags} />)
})
return(
<ul id="item-list">
{itemList}
</ul>
)
}
So the issue here is that item.tags is an array. From within my component, I am just doing something simple like display the name and then loop through the tags to display them:
render: function(){
var tags = [];
this.props.tags.forEach(function(tag){
tags.push( <li>{tag}</li> />)
})
return(
<li>
<h1>{this.props.name}</h1>
<ul>
{tags}
</ul>
</li>
)
}
From within the component, tags is undefined.
What do I do/am I doing wrong, because I am very new to React. Thanks!