Skip to content

Commit 6e74b73

Browse files
ISSUE-458 Make removeValueFromArray a pure function (#459)
1 parent e60742e commit 6e74b73

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib/utils.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ export const sumNumericArray = (arr: number[]) =>
2626

2727
export const removeValueFromArray = (value: any, array: any[]): any[] => {
2828
const index = array.indexOf(value);
29+
const newArray = [...array];
2930
if (index > -1) {
30-
array.splice(index, 1);
31+
newArray.splice(index, 1);
3132
}
32-
return array;
33+
return newArray;
3334
};
3435

3536
export const isValueInArray = (value: any, array: any[]): boolean => {

0 commit comments

Comments
 (0)