import React from 'react'; import Box from '../partials/box'; import Api from '../api'; class Category extends React.Component { state = { category: {}, items: [], currentLoaded: config.loadingItems, moreLoaded: false, moreToLoad: true }; componentWillReceiveProps(nextProps) { this.setState({ category: {}, items: [] }); this.loadCategoryItems(nextProps); } constructor(props) { super(props); this.loadCategoryItems(props); } // todo: fix icon load. render() { return (
{this.state.items.length ? : }
); } loadCategoryItems(props) { setTimeout(() => { Api.categoryItems(props.params.category).then((value) => { this.setState({ category: value.category, items: value.items }); }); }, 200); } } export default Category;