Skip to content

Instantly share code, notes, and snippets.

@olegkalyta
Last active September 26, 2018 08:15
Show Gist options
  • Save olegkalyta/b823b14527e8ddf7ae93cf76d993ea1f to your computer and use it in GitHub Desktop.
Save olegkalyta/b823b14527e8ddf7ae93cf76d993ea1f to your computer and use it in GitHub Desktop.
const Filter = ({ categories, selectedCategories, toggleCategory }) => {
const extendedCategories = categories.map(c => ({
...c,
isShown: selectedCategories.find(sc => sc.id === c.id),
}))
return (
<View style={{ flex: 1 }}>
<FlatList
data={extendedCategories}
keyExtractor={i => i.id}
renderItem={({ item }) => (
<FilterItem category={item} key={item.id} onClick={toggleCategory} />
)}
/>
</View>
)
}
const connectedFilter = connect(
state => ({
categories: state.categories,
selectedCategories: state.selectedCategories,
}),
{ toggleCategory: actions.toggleSelectedCategory }
)(Filter)
export default connectedFilter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment