I have a component where I am mapping through an array of items. I am adding a filter to it as well. Right now it looks like this:
{data.products
.filter((item) => item.acf.quiz.gender.some(({ value }) => value === state.theme.quiz.quizGender))
.map((item, id) => {
return <ProductCard key={id} item={item} data={data} />;
})
}
So if the gender has been set to state by a radio button in another component, the map will filter by items where that gender is an attribute. I have that part working just fine.
What I am trying to figure out though, is if there is a way to conditionally apply that filter, so that if the use didn't set their gender, then the filter would not apply. I know there is a way to do this outside of the map, but I am needing to do it inline with this .filter() as there will be several more filters that I will need to apply.
Any help would be great.