-
Notifications
You must be signed in to change notification settings - Fork 20
mapDispatchToProps is wrong #2
Comments
Wrong in what way? |
Maybe because original redux actions simply return objects: function myAction() {
return { type: 'MY_ACTION' };
} redux-thunk should be an optional package. In the function myAction() {
return dispatch => dispatch({ type: 'MY_ACTION' });
} |
Ah, good point on thunk, I tend to always include it so over looked this. Thoughts on making thunk required? Makes it so much easier to build actions |
Yes it is a very handy package. In my opinion it would be great to have the In fact, import { updateUserInput } from 'myActions.js';
const mapDispatchToProps = {
updateUserInput
}; But the classic way is more like this: import { updateUserInput } from 'myActions.js';
const mapDispatchToProps = (dispatch) => ({
updateUserInput: value => dispatch(updateUserInput(value))
}); And letting the user manage the way he like dispatching actions, like, for example, using the import { updateUserInput } from 'myActions.js';
const mapDispatchToProps = (dispatch) => bindActionCreators({updateUserInput}, dispatch); |
Also I'm realizing that |
Any updates on this? |
When attempting to integrate with rematch, not being able to pass a function to mapDispatchToProps causes this to break, since the library expects actions to be mapped this way. |
When I use |
The implementation of mapDispatchToProps seems to be wrong.
I think this is more appropriate implementation.
The text was updated successfully, but these errors were encountered: