Skip to content

Instantly share code, notes, and snippets.

@hannigand
Created February 22, 2017 12:03
Show Gist options
  • Save hannigand/36368254d9d89746d24d0d277e57844e to your computer and use it in GitHub Desktop.
Save hannigand/36368254d9d89746d24d0d277e57844e to your computer and use it in GitHub Desktop.
getActiveItems() {
const { filterVideos, videos, structuredVideos, unstructuredVideos} = this.state;
let item = null;
let activeItem = null;
if(!filterVideos || filterVideos === 'all') {
item = videos
activeItem = 'all';
} else if (filterVideos === 'structured') {
item = structuredVideos;
activeItem = 'structured';
} else if ( filterVideos === 'unstructured') {
item = unstructuredVideos;
activeItem = 'unstructured';
}
return { item, activeItem }
}
render() {
const { item, activeItem } = this.getActiveItems();
return (
<View>
<ScrollView>
<View style={ styles.container }>
<InfoBar
message="Please note, your CPD record can take up to 24 hours to update"
/>
<TabBar
filterVideos={ this.filterVideos }
setActive={ activeItem } />
{
item
.map(video =>
<PlaylistItem
style={ { flex: 1 } }
key={ video.id }
video={ video }
updateStatement={ this.updateStatement }
/>
)
}
</View>
</ScrollView>
</View>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment