I have a search bar, a drowdown and a filtered list which currently works as it should, but what I want to do is replace 'name' in filterV.product.name with a value selected from a dropdown.
const filterArray = ["name", "description", "condition", "purpose", "category"];
one of these values should replace name when the user selects it from the dropdown and searches with the filter on.
{this.state.filteredContent.length > 0 ? this.state.filteredContent.filter((filterV) => {
return filterV.product.name.toLowerCase().indexOf(this.state.searchValue.toLowerCase()) !== -1
}).map((item, index) => (
<div key={index}>
<ProductItem
goToLink={true}
delete={false}
edit={false}
remove={false}
duplicate={false}
item={item}
hideMore
/>
</div>
)): null}
any help much appriciated.
also even though the filter function is working and displaying the list on screen correctly, when I console.log this.state.filteredContent the length never changes, any ideas how I can get the correct list of filtered objects?
the list comes throught redux props
this.state = {
searchValue: '',
filterValue: '',
filteredContent: props.productWithoutParentList.length > 0 ? props.productWithoutParentList : [],
}
["name", "description", "condition", "purpose", "category"]is options of dropdown andproductcontains there properties? Would be a lot easier to understand if you could create a minimal reproducible example