Skip to content

Commit 2c4037f

Browse files
committed
create new array using spread operator
1 parent 0359344 commit 2c4037f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/hooks/usePlanOptimistic.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const reducer = (state: PlanType | null, action: Action): PlanType | null => {
3737
};
3838

3939
case "addImage": {
40-
let images = state?.images || action.init;
40+
let images = [...(state?.images || action.init)];
4141

4242
images.push(action.payload);
4343

@@ -48,7 +48,7 @@ const reducer = (state: PlanType | null, action: Action): PlanType | null => {
4848
}
4949

5050
case "addPlace": {
51-
let stops = state?.stops || action.init;
51+
let stops = [...(state?.stops || action.init)];
5252

5353
if (!stops.find((p) => p.placeId === action.payload.placeId))
5454
stops.push(action.payload);
@@ -57,7 +57,7 @@ const reducer = (state: PlanType | null, action: Action): PlanType | null => {
5757
}
5858

5959
case "removePlace": {
60-
let stops = state?.stops || action.init;
60+
let stops = [...(state?.stops || action.init)];
6161

6262
return {
6363
...state,

0 commit comments

Comments
 (0)