You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
"description":"Pass an action as a second param to the reducer",
32
-
"tests": [
33
-
"04/03"
14
+
"05/01"
34
15
]
35
16
},
36
17
{
37
-
"description":"Dispatch two voteUp actions through the reducer: `store.dispatch(voteUp(2))`. Change your log statement inside ofyourreducer to look like this: `console.log('state: ', state, 'action: ', action)`",
18
+
"description":"Let's make a test to see that we are truly returning a new state. Wrapyour`initialState` object in a `Object.freeze`. Freeze makes an object unchangeable. And yet your reducer should still work.",
38
19
"tests": [
39
-
"04/04"
20
+
"05/02"
40
21
]
41
22
},
42
23
{
43
-
"description":"Create a `switch` statement and pass in `action.type`,thedefault return shouldreturn`state`",
24
+
"description":"What if we were dealing with multiple keys onthestate. We'd have to ensure that our changesreturna complete newstate each time. Use `Object.assign`",
44
25
"tests": [
45
-
"04/05"
46
-
]
47
-
},
48
-
{
49
-
"description":"The `switch` statement should have a `default` case that returns the state",
50
-
"tests": [
51
-
"04/06"
52
-
]
53
-
},
54
-
{
55
-
"description":"add a switch case for `VOTE_UP`. For now, just console.log the `id` of the action passed in and return the default state again.",
Copy file name to clipboardExpand all lines: tutorial/04/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,5 +36,5 @@ const reducer = (state) => {
36
36
+ The`switch` statement should have a`default` case that returns the state
37
37
@test('04/06')
38
38
39
-
+ add a switch case for`VOTE_UP`. For now, just console.log the`id` of the action passed in and return the default state again.
39
+
+ add a switch case for`VOTE_UP`. For now, just console.log the`id` of the action passed in and return the default state again. Tip: destructuring:`const { id } = action.payload;`
+ Return a new list of Pokemonwith the pokemon matching theid incrementing its votes by one
19
+
+ Return a new list of Pokemonafter incrementing "votes" of thepokemon with the matching "id"
17
20
@test('05/01')
18
21
19
-
20
-
21
-
+ Use Object.assign
22
+
+ Let's make a test to see that we are truly returning a new state. Call`Object.freeze()` on your`initialState`.`freeze` makes an object immutable - meaning the object can not be changed. And yet your reducer should still work, since it returns a new state each call.
22
23
@test('05/02')
24
+
25
+
+ What if we were dealing with multiple keys on the state. We'd have to ensure that our changes return a complete new state each time. Use`Object.assign`