Created
July 15, 2022 10:44
-
-
Save hesan-aminiloo/42210232436e3d2f4ec7715ae9e85b7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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