-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a structural thing, otherwise 👍
`Expected defaultState for reducer handling ${actionTypes.join(', ')} to be defined` | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally that's a good idea to extract the assertions 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we will rewrite this later with invariant
, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, or we may as well do it now.
Btw, I've changed the base branch to |
handlers[type], | ||
defaultState | ||
) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relevant: #108
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.