Skip to content

Commit

Permalink
fix: use deep clone prevent mutate filter
Browse files Browse the repository at this point in the history
  • Loading branch information
newarifrh committed Jul 10, 2024
1 parent 48d4b7d commit 9cf184e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/types/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const initialFilterConfig: Record<FilterType, Partial<Filter>> = {
activity: { team: [], category: [] },
};

export const createInitialFilter = (type: FilterType): Filter => {
return initialFilterConfig[type];
const deepClone = <T>(obj: T): T => {
return JSON.parse(JSON.stringify(obj));
};

export const createInitialFilter = (type: FilterType): Filter => {
return deepClone(initialFilterConfig[type]);
}

0 comments on commit 9cf184e

Please sign in to comment.