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": "Refactor your project into different files.",
8
+
"title": "The Store",
9
+
"description": "The \"single source of truth\".\n\n```js\nconst store = createStore(reducer, initialState);\n```",
10
10
"tasks": [
11
11
{
12
-
"description": "create a folder in your base directory called \"pokemon\" and add a file inside called \"index.js\"",
12
+
"description": "install Redux.",
13
+
"hints": [
14
+
"Run `npm install --save redux`."
15
+
],
16
+
"actions": [
17
+
"open('index.js')"
18
+
],
13
19
"tests": [
14
-
"07/01"
20
+
"02/01"
15
21
]
16
22
},
17
23
{
18
-
"description": "take your `VOTE_UP` action type from \"index.js\" and put it in \"pokemon/index.js\"",
19
-
"tests": [
20
-
"07/02"
24
+
"description": "import `createStore` from the redux module.",
25
+
"hints": [
26
+
"Add `import { createStore } from 'redux';`"
21
27
],
28
+
"tests": [
29
+
"02/02"
30
+
]
31
+
},
32
+
{
33
+
"description": "create your first store and call it `store`. Use a simple \"reducer\" function for now, let's say `state => state`.",
22
34
"hints": [
23
-
"\"pokemon/index.js\" should have `const VOTE_UP = 'VOTE_UP';`"
35
+
"declare your store, `const store`",
36
+
"call store with a simple reducer, `const store = createStore(state => state)`"
37
+
],
38
+
"tests": [
39
+
"02/03"
24
40
]
25
41
},
26
42
{
27
-
"description": "take your `voteUp` action creator from \"index.js\"and put it in \"pokemon/index.js\". Export it as a [\"named\" export](https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export).",
43
+
"description": "log your store to the console and have a look.",
28
44
"tests": [
29
-
"07/03"
45
+
"02/04"
30
46
],
31
47
"hints": [
32
-
"move `voteUp` into \"pokemon/index.js\"",
33
-
"\"pokemon/index.js\" should have `const voteUp = id => ({ type: VOTE_UP, payload: { id } });`"
48
+
"console.log(store)"
34
49
]
35
50
},
36
51
{
37
-
"description": "take your `pokemon` reducer from \"index.js\" and put it in \"pokemon/index.js\". Export the reducer as a \"default\" export",
52
+
"description": "log `store.getState()` to the console",
38
53
"tests": [
39
-
"07/04"
54
+
"02/05"
55
+
],
56
+
"hints": [
57
+
"console.log(store.getState())"
40
58
]
41
59
},
42
60
{
43
-
"description": "in your \"index.js\" file, import the action creators and reducer in one line of code.",
61
+
"description": "move the initial state to the top of the file, and pass it in as a second param your `createStore`",
44
62
"tests": [
45
-
"07/05"
63
+
"02/06"
46
64
],
47
65
"hints": [
48
-
"Try this: `import { default as pokemon, voteUp } from './pokemon';`"
66
+
"Move `initialState` above your `store`",
67
+
"Pass in `initialState` as a second param to `createStore`"
68
+
],
69
+
"actions": [
70
+
"insert('const initialState = {\n pokemon: [{\n id: 1,\n name: 'Luvdisc',\n description: 'This heart-shaped POKéMON earned its name by swimming after loving couples it spotted in the ocean’s waves.',\n votes: 3\n }, {\n id: 2,\n name: 'Trubbish',\n description: 'Wanting more garbage, they follow people who litter. They always belch poison gas.',\n votes: 2\n }, {\n id: 3,\n name: 'Stunfisk',\n description: 'Its skin is very hard, so it is unhurt even if stepped on by sumo wrestlers. It smiles when transmitting electricity.',\n votes: 0\n }]\n };\n')"
49
71
]
50
72
}
51
73
],
52
-
"onPageComplete": ""
74
+
"onPageComplete": "As you can see, the store is just an object with various methods like \"dispatch\" and \"getState\". Let's see what these methods do in the next step."
0 commit comments