We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent daf2d6c commit a4718d4Copy full SHA for a4718d4
README.md
@@ -562,18 +562,21 @@ be very expensive in terms of performance.
562
563
**Bad:**
564
```javascript
565
-function (state, action) {
566
- state.userProfile = action.payload;
567
- return state;
+const addItemToCart = function (cart, item) {
+ cart.push({ item: item, date: Date.now() });
+
568
+ return cart;
569
}
570
```
571
572
**Good:**
573
-function userReducer(state, action) {
574
- var s = Object.assign({}, state);
575
- s.userProfile = action.payload;
576
- return s;
+ const c = Object.assign({}, cart);
577
+ c.push({ item: item, date: Date.now() });
578
579
+ return c;
580
581
582
0 commit comments