Skip to content

Instantly share code, notes, and snippets.

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 hesan-aminiloo/42210232436e3d2f4ec7715ae9e85b7b to your computer and use it in GitHub Desktop.
Save hesan-aminiloo/42210232436e3d2f4ec7715ae9e85b7b to your computer and use it in GitHub Desktop.
const filterBrands = (brands, term) => {
return brands.filter((brand) =>
brand.name.toLowerCase().includes(term.toLowerCase()),
);
};
const BrandsSidebar = () => {
const [brands] = useBrands();
const [filter, setFilter] = useState('');
return (
<div>
<input
type="text"
value={filter}
onChange={({ target }) => setFilter(target.value)}
/>
{filterBrands(brands, filter).map((brand) => (
<BrandItem brand={brand} />
))}
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment