I have come across an issue in which there is a hash which contains a label, index, visible
and I need to order the component according to the index
value, it should be visible if visible is true
.
These are my components:
render(){
return(
<GroupFeaturedCarousel {...this.props}/>
<GroupAssignmentCarousel {...this.props}/>
<GroupSharedCarousel {...this.props}/>
<GroupChannelCarousel {...this.props}/>
)
}
and array of hashes is this:
myArray = [
{default_label: "Featured", index: 0, visible: true},
{default_label: "Assigned", index: 1, visible: true},
{default_label: "Shared", index: 2, visible: true},
{default_label: "Channels", index: 3, visible: true}]
All I can think of solving this is by using _.sortBy(myArray, 'index')
but then how can I implement this?
Need to consider sort and visible both.