Skip to content

Instantly share code, notes, and snippets.

@jsrath
Last active January 5, 2019 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsrath/d59411e0042d7788564ab82986f0d502 to your computer and use it in GitHub Desktop.
Save jsrath/d59411e0042d7788564ab82986f0d502 to your computer and use it in GitHub Desktop.
filterByBrand = event => {
this.setState({ brand: event.target.value }, () => {
const filtered = this.state.items.filter(item =>
item.manufacturer.toLowerCase()
.includes(this.state.brand.toLowerCase()),
);
this.setState({ filtered });
});
};
filterByRating = event => {
this.setState({ rating: event.target.value.slice(0, 1) }, () => {
const filtered = this.state.items.filter(item =>
item.rating >= this.state.rating);
this.setState({ filtered });
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment