Skip to content

Commit 20a12e0

Browse files
committed
final check - steps 5-7
1 parent a993913 commit 20a12e0

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

coderoad.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
"description": "In Redux, we are not limited to writing a long, single reducer. Using `combineReducers` allows us to create modular, composable reducers.\n\nAs our state is an object, for example:\n\n```js\n{\n pokemon: [ ... ],\n users: [ ... ]\n}\n```\n\nWe can create a reducer to handle data transformations for each key in our state.\n\n```js\n{\n pokemon: pokemonReducer,\n users: usersReducer\n}\n```\n\nAs our app grows, we can now think of the data in smaller chunks.\n\n> [Learn more](http://redux.js.org/docs/api/combineReducers.html).\n\nLet's try refactoring our app to use `combineReducers`.",
278278
"tasks": [
279279
{
280-
"description": "create a new `const reducers` and set it equal to \"reducer\". Pass \"reducers\" into your store for now, instead of \"reducer\". If this seems convoluted it is because we're trying not to break the app.",
280+
"description": "create a new `const reducers` and set it equal to \"reducer\". Pass \"reducers\" into your store for now, instead of \"reducer\". If this seems convoluted it is because we're trying not to break the app. Also comment out any `store.dispatch`'s until the change is complete.",
281281
"tests": [
282282
"06/01"
283283
],
@@ -351,12 +351,12 @@
351351
]
352352
},
353353
{
354-
"description": "`reducers` should now call `combineReducers` instead and call `pokemon`. `combineReducers` takes an object with keys of each reducer.",
354+
"description": "`reducers` should now call `combineReducers` instead and call `pokemon`. `combineReducers` takes an object with keys of each reducer. See the [docs](http://redux.js.org/docs/api/combineReducers.html).",
355355
"tests": [
356356
"06/08"
357357
],
358358
"hints": [
359-
"Try this: `const reducers = combineReducers({pokemon});`"
359+
"Try this: `const reducers = combineReducers({ pokemon });`"
360360
]
361361
}
362362
],
@@ -367,7 +367,7 @@
367367
"description": "Our \"index.js\" file is getting a little long. Of course, our app will be more maintainable if we can divide it across different, well structured files.\n\nThere are different ways of structuring your app:\n\n##### 1. Files By Type\n\n- store.js\n- action-types.js\n- action-creators.js\n- reducers.js\n\n##### 2. Files By Function\n\n- store.js\n- reducers.js\n- modules\n - pokemon\n - index.js\n\n##### 3. Files by Function & Type\n\n- store\n- reducers.js\n- modules\n - pokemon\n - actions.js\n - reducer.js\n - action-types.js\n\nFor simplicity in this example, we'll try putting our files together by function.",
368368
"tasks": [
369369
{
370-
"description": "create a folder in your base directory called \"pokemon\" and add a file inside called \"index.js\"",
370+
"description": "create a new folder in your \"src\" directory called \"pokemon\" and add a file inside called \"index.js\"",
371371
"tests": [
372372
"07/01"
373373
],
@@ -401,7 +401,7 @@
401401
"07/04"
402402
],
403403
"hints": [
404-
"Try this: `import { voteUp } from './pokemon';`"
404+
"Try this: `const voteUp = require('./pokemon').voteUp;`"
405405
]
406406
},
407407
{
@@ -422,11 +422,12 @@
422422
"07/07"
423423
],
424424
"hints": [
425-
"Try this: `import { default as pokemon, voteUp } from './pokemon';`"
425+
"Normally we write this: `const { default as pokemon, voteUp } from './pokemon';`",
426+
"Due to a current issue in CodeRoad, we must write: `const pokemon = require('./pokemon').default;`"
426427
]
427428
}
428429
],
429-
"onPageComplete": "Page 7 complete..."
430+
"onPageComplete": "Now that our project is more organized, we'll look at one of the most powerful features of Redux: middleware"
430431
},
431432
{
432433
"title": "Logger",

tutorial/06/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ As our app grows, we can now think of the data in smaller chunks.
2525
2626
Let's try refactoring our app to use `combineReducers`.
2727

28-
+ create a new `const reducers` and set it equal to "reducer". Pass "reducers" into your store for now, instead of "reducer". If this seems convoluted it is because we're trying not to break the app.
28+
+ create a new `const reducers` and set it equal to "reducer". Pass "reducers" into your store for now, instead of "reducer". If this seems convoluted it is because we're trying not to break the app. Also comment out any `store.dispatch`'s until the change is complete.
2929
@test('06/01')
3030
@action(open('src/index.js'))
3131
@hint('First, try this: `const reducers = reducer;`')
@@ -62,9 +62,9 @@ Let's try refactoring our app to use `combineReducers`.
6262
@test('06/07')
6363
@hint('Try this: `import { combineReducers } from 'redux';`')
6464

65-
+ `reducers` should now call `combineReducers` instead and call `pokemon`. `combineReducers` takes an object with keys of each reducer.
65+
+ `reducers` should now call `combineReducers` instead and call `pokemon`. `combineReducers` takes an object with keys of each reducer. See the [docs](http://redux.js.org/docs/api/combineReducers.html).
6666
@test('06/08')
67-
@hint('Try this: `const reducers = combineReducers({pokemon});`')
67+
@hint('Try this: `const reducers = combineReducers({ pokemon });`')
6868

6969

7070
@onPageComplete('The state remains the same, but now our reducers are much more modular. In the next step, we will separate our code into it's own file')

tutorial/07/04.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
describe('04 voteUp', () => {
22

3-
it('should get imported in "pokemon/index.js"', () => {
3+
it('should be in "src/index.js"', () => {
44
const voteUp = indexJs.__get__('voteUp');
55
expect(voteUp).to.not.be.undefined;
66
expect(typeof voteUp).to.equal('function');
77
});
88

9+
it('should be imported in "src/index.js"', () => {
10+
const input = indexJs.__text__;
11+
const regex = /import.*voteUp|voteUp.*require/;
12+
expect(input).to.match(regex);
13+
});
14+
915
});

tutorial/07/07.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
describe('07 import', () => {
1+
describe('07 pokemon reducer', () => {
22

3-
it('`default as pokemon` from "./pokemon" in "index.js"', () => {
3+
it('should be in "src/index.js"', () => {
44
const pokemon = indexJs.__get__('pokemon');
55
expect(pokemon).to.not.be.undefined;
66
expect(typeof pokemon).to.equal('function');
77
});
88

9+
it('should be imported in "src/index.js"', () => {
10+
const input = indexJs.__text__;
11+
const regex = /import\s?pokemon|pokemon.*require.*default/;
12+
});
13+
914
});
1015

1116
describe('07 cleanup index.js by deleting', () => {

tutorial/07/index.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ There are different ways of structuring your app:
3030

3131
For simplicity in this example, we'll try putting our files together by function.
3232

33-
+ create a folder in your base directory called "pokemon" and add a file inside called "index.js"
33+
+ create a new folder in your "src" directory called "pokemon" and add a file inside called "index.js"
3434
@test('07/01')
3535
@hint('create a file in "src/pokemon/index.js"')
3636

@@ -46,7 +46,7 @@ For simplicity in this example, we'll try putting our files together by function
4646

4747
+ import `voteUp` inside of "src/index.js". Also delete the unnecessary 'voteUp' in the same file from before.
4848
@test('07/04')
49-
@hint('Try this: `import { voteUp } from './pokemon';`')
49+
@hint('Try this: `const voteUp = require('./pokemon').voteUp;`')
5050

5151
+ take the `defaultPokemon` from "src/index.js" and copy it into "src/pokemon/index.js"
5252
@test('07/05')
@@ -56,6 +56,7 @@ For simplicity in this example, we'll try putting our files together by function
5656

5757
+ in your "src/index.js" file, also import your pokemon reducer. This can be on the same line of code. Delete the unnecessary original "pokemon", "defaultPokemon" and "VOTE_UP" as well.
5858
@test('07/07')
59-
@hint('Try this: `import { default as pokemon, voteUp } from './pokemon';`')
59+
@hint('Normally we write this: `const { default as pokemon, voteUp } from './pokemon';`')
60+
@hint('Due to a current issue in CodeRoad, we must write: `const pokemon = require('./pokemon').default;`')
6061

61-
@onPageComplete('Page 7 complete...')
62+
@onPageComplete('Now that our project is more organized, we'll look at one of the most powerful features of Redux: middleware')

0 commit comments

Comments
 (0)