Skip to content

Commit

Permalink
[FIX] Inefficient selectors (#3359)
Browse files Browse the repository at this point in the history
Fix spread inefficiency
  • Loading branch information
sggerard authored Jan 6, 2025
1 parent 5c87288 commit a59efe5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 2 additions & 4 deletions services/common/src/redux/selectors/staticContentSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,8 @@ export const getHSRCMComplianceCodesHash = createSelector([getCurrentComplianceC
.filter(({ article_act_code }) => article_act_code === "HSRCM")
.reduce((map, code) => {
const composedValue = formatComplianceCodeValueOrLabel(code, true);
return {
[code.compliance_article_id]: composedValue,
...map,
};
map[code.compliance_article_id] = composedValue;
return map;
}, {})
);

Expand Down
8 changes: 6 additions & 2 deletions services/common/src/redux/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ export const createDropDownList = (
};

// Function to create a hash given an array of values and labels
export const createLabelHash = (arr) =>
arr.reduce((map, { value, label }) => ({ [value]: label, ...map }), {});
export const createLabelHash = (arr) => {
return arr.reduce((map, { value, label }) => {
map[value] = label;
return map;
}, {});
};

export const formatTractionDate = (dateString: string) => {
const year = dateString.slice(0, 4);
Expand Down

0 comments on commit a59efe5

Please sign in to comment.