-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
What is the reasoning for making redux validate action object? #1360
Comments
This decision was taken because way too many people had problems with reducers not handling the actions. Turns out, usually it happened due to a typo when importing a constant in the reducer file: import { INRCEMENT } from './actions' Of course the matching We felt this is a good enough reason to choose a single convention (in our case, the most popular one is the one that comes from Flux: The developer efficiency that we get from this tradeoff seems worthy to me. The only reason Canonical Composition does not fit this pattern is because it insists on using Previous discussions:
We don’t plan to change this. |
Sounds a lot like a responsibility of a dev middleware (validateAction) to me, esp. given that this should only be done in development setup. I respect your decision though.
|
The problem with this specific mistake is you don’t know you need that middleware until you’ve spent an hour on this and it’s too late :-) I know it’s opinionated but I think we made the right tradeoff here. |
https://github.com/rackt/redux/blob/v3.2.1/src/createStore.js#L156-L161
There is no reason for Redux to perform this validation. Redux must only concern itself with the actions that it dispatches (namely,
ActionTypes. INIT
).The workaround that is used at the moment (e.g. projects that implement https://github.com/gajus/canonical-reducer-composition) is to set
action.type
to a dummy property only to satisfy this single condition, which appears both a hack and unnecessary.I'd like to propose to remove this condition.
The text was updated successfully, but these errors were encountered: