-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
suggestion: add info about dispatched action types #45
Comments
I agree that sometime it make sense, especially when you declare your component and connect in the same file, but it also makes a component more coupled to the actions, so I'm not really convinced to recommend it as a good practice but rather I think of it as a developer preference |
@BoostIO funded this issue with $25. Visit this issue on Issuehunt |
@issuehuntfest has funded $15.00 to this issue. See it on IssueHunt |
After some consideration I think it would be good to add it to the guide, especially in case when you don't care about tightly coupling your components to actions then it can be really beneficial because there will be less manual maintenance of types declarations and much better error reporting (at Props type declaration instead of more complex error at connect location). |
By the way, the dispatchProps return type would be the return type of the action creator. Was this supposed to be
Shouldn't be derived as below from the types?
|
When declaring a
connect
ed component's property types I find it helpful to use thetypeof
operator to declare dispatched function types so that the property matches the action's declaration:The text was updated successfully, but these errors were encountered: