React-redux type for connect does not allow mapDispatchToProps as function anymore
See original GitHub issueI’m getting the following flow error with the new react redux flow types, when using connect
with a mapDispatchToProps
function. The error does not occur when using an object instead.
• Either function [1] is not an object.
• Or ST [2] is not a React component.
flow-typed/npm/react-redux_v5.x.x.js
[2] 132│ ST: $Subtype<{[_: $Keys<Com>]: any}>
[1] 75│ const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({
76│ someProp: () => dispatch(someAction()),
77│ });
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Connect: Dispatching Actions with mapDispatchToProps
React Redux gives you two ways to let components dispatch actions: By default, a connected component receives props.dispatch and can dispatch ...
Read more >Can't connect components with mapDispatchToProps
The mapDispatchToProps is the second argument of the connect function from the react-redux. I also think that you pass wrong the first ...
Read more >How to deal with failure in Redux connect - Medium
But connect 's API from react-redux doesn't allow this. We can achieve this logic with an intermediary component. It can accept 2 props:....
Read more >Defining and Using React Redux mapDispatchToProps
We use the connect function to do it. React Redux gives us 2 ways to let our components dispatch actions. We can either...
Read more >MapStateToProps and MapDispatchToProps in React Redux
Then we throw this function inside connect and every single time when our state changes this function will be called and give us...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sherwinyu no I have not. I’ve pretty much have had to do the same thing. In some cases where we could I’ve modified
mapDispatchToProps
to immediately return an object, which fixes the issue, however there are lots of cases where we need the dispatch function to properly map. Would be great if someone could chime in with an appropriate fix.@amccloud I’m having the same issue as @joshuajaco and we are using a custom
Dispatch
type.