Design comparison
SolutionDesign
Solution retrospective
What specific areas of your project would you like help with?
filtering is hard and i need to be more comfortable with it
Community feedback
- @markuslewinPosted about 2 months ago
The trick is to realize you actually only need state for
appliedFilters
. The rest of the UI can be derived fromdata
andappliedFilters
:import jobs from "./data.json"; function App() { const [appliedFilters, setAppliedFilters] = useState([]); const filteredJobs = jobs.filter((job) => filters.every((filter) => [job.role, job.level, ...job.languages, ...job.tools].includes(filter) ) ); return <></> }
Now, you only need to add/remove filters, and
filteredJobs
will be recalculated every timeappliedFilters
updates!0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord