Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab29de6

Browse files
Merge pull request ryanmcdermott#152 from Gregoirevda/patch-1
Immutable error
2 parents ff6fdc1 + 55ec74a commit ab29de6

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,11 +602,7 @@ const addItemToCart = (cart, item) => {
602602
**Good:**
603603
```javascript
604604
const addItemToCart = (cart, item) => {
605-
const c = Object.assign({}, cart);
606-
607-
c.push({ item, date: Date.now() });
608-
609-
return c;
605+
return [...cart, { item, date : Date.now() }];
610606
};
611607
```
612608

0 commit comments

Comments
 (0)