import React from 'react'; import Router from 'react-router'; import FilterOptions from './filter-options'; import Item from './item'; import Api from '../api'; let Link = Router.Link; class Box extends React.Component { state = { // No need to sync parent items. items: this.props.items } render() { let items = this.state.items.map((value, key) => { return }); return (
{this.props.category.name} ({this.props.category.items_count.aggregate})
{ ! this.state.items.length ? : items}
); } changeFilter(filterBy, category) { Api.changeUsersFilterFor(category, filterBy); this.setState({ items: [] }) setTimeout(() => { Api.items(this.props.type, this.props.category.slug, filterBy).then((value) => { this.setState({ items: value.items }); }) }, 200); } } export default Box;