I only want to render array values as elements, if the array has values and exists. In my case there is an array of colors, the user can set the current color_theme, which is represented by its index. On start there should no color_theme be chosen. My render function will try to render the current color_color_theme, but there is noch current_color_index. How can I check if there is an exsiting colorsheme before the rendering? I cannot write a return before the redering, because there are other elements, that have to be rendered.
data = {
"colorthemes" : [ ["blue","red"], ["black","grey"] ],
"current_color_index": "",
....//more
}
render: function() {
return (
<div>
<ul>
//other stuff is rendering
</ul>
<ul>
{this.state.data.colorthemes[this.state.data.current_color_index].map(function(item, i) {
....
}, this)}
</ul>
</div>