Skip to content

Instantly share code, notes, and snippets.

@johnnykoo84
Created April 17, 2019 14:53
Show Gist options
  • Save johnnykoo84/993a7aa1ee74870c2df254ed7dd490a4 to your computer and use it in GitHub Desktop.
Save johnnykoo84/993a7aa1ee74870c2df254ed7dd490a4 to your computer and use it in GitHub Desktop.
changeCurrentCategory = userSelectedCategory => {
const { allArticles } = this.state;
const category = this.categories.find(category => category.name === userSelectedCategory);
this.setState({
currentCategory: category.name,
currentArticles: allArticles
.filter(post => post.UserId === category.id)
.slice(0, this.articlesPerPage),
currentPage: 1
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment