Make defaultState required when creating reducers#127
Conversation
|
We are explicitly requiring it, so let's note it as breaking change, regardless of how Redux is handling it. |
timche
left a comment
There was a problem hiding this comment.
Only a structural thing, otherwise 👍
| `Expected defaultState for reducer handling ${actionTypes.join(', ')} to be defined` | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
I'd suggest to move this function to a folder named utils and name that file assertions.js or sth like this, where we can write more functions like this in a single file.
There was a problem hiding this comment.
Generally that's a good idea to extract the assertions 👍
There was a problem hiding this comment.
Also, we will rewrite this later with invariant, correct?
There was a problem hiding this comment.
Yes, or we may as well do it now.
|
Btw, I've changed the base branch to |
| handlers[type], | ||
| defaultState | ||
| ) | ||
| ); |
Close #18.
See that issue and also reduxjs/redux#514 for background and discussion.
TL;DR
We can prevent downstream reducer sanity errors like this one by throwing earlier.