1. 5
    Redux: Writing a Counter Reducer with Tests
    2m 36s

Redux: Writing a Counter Reducer with Tests

Share this video with your friends

Send Tweet

You will learn how to write the reducer for the counter application in a test driven development way, as well as the conventions in implementing reducers.

Nathaniel
Nathaniel
~ 9 years ago

Would you mind explaining more as to why you define counter as a const and an arrow function? What is meant by it has clearer semantics? Thanks so much, really enjoying the series so far!

Dan Abramov
Dan Abramov(instructor)
~ 9 years ago

Nathaniel,

For historical reasons JS function declarations have weird semantics. "function" is not block-scoped (that it, behaves like "var" rather than like ES6 "let" or "const"), it is hoisted (a very weird thing to cloud beginners' heads with), it has "this" context which is frustrating to explain when you're just teaching some library's API, etc.

See also:

https://medium.com/@ryanflorence/functions-without-function-bc356ed34a2f

https://twitter.com/sebmarkbage/status/638531311477522433

rphansen91
rphansen91
~ 8 years ago

Which library are you using for expect?

rphansen91
rphansen91
~ 8 years ago

Figured out through later episodes it is loaded through as a script tag on the HTML src="https://wzrd.in/standalone/expect@latest". Loving the series so far, same architecture as ELM but with JS!

Ferenc
Ferenc
~ 8 years ago

If anyone wondering:

https://github.com/mjackson/expect

Janis
Janis
~ 5 years ago

Is expect a thing from expect.js that I need to npm install? Also what environment should I use for this mini tutorial series?