Skip to content

Lifting up filter logic #846

Answered by doemser
SabinePfanner asked this question in Web
Discussion options

You must be logged in to vote

Here is a small prototype on how you could go for this feature:

https://stackblitz.com/edit/vitejs-vite-um13ib?file=src%2FApp.jsx,src%2Fmain.jsx&terminal=dev

In your current code I see one major issue:

  let filteredPlants;

  filteredPlants = plants.filter(..);

  filteredPlants = filteredPlants.filter(..);

  filteredPlants = filteredPlants.filter(..);

you should write it like this, without mutating a let:

const filterForX = plants.filter(..);
const filterForY = filterForX.filter(..);
const filterForZ = filterForY.filter(..);

Also in your multiselects you are declaring styled components inside another component, you should avoid declaring components in components

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by doemser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants