Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mattupham committed Sep 10, 2024
1 parent e1b7098 commit f5ca4f5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/web/components/earn/filters/filter-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ export const FilterProvider = ({

return setFilters((prev) => {
const prevArray = prev[key] as ListOption<string>[];
/**
* This code chooses what new array
* to return based on the existence of the incoming filter value.
*
* If the incoming value is already present in the state value,
* then remove it. If it doesn't, then add it.
*/
const newArray = exists
? prevArray.filter(
(prevOption) => prevOption.value !== filterValue.value
Expand Down

0 comments on commit f5ca4f5

Please sign in to comment.