Closed Vanuan closed 4 years ago
Hey @Vanuan Yes, an example is here: https://github.com/piotrwitek/react-redux-typescript-guide#--redux-connected-counter-with-redux-thunk-integration
use this:
const mapDispatchToProps = (dispatch: Dispatch<Types.RootAction>) =>
bindActionCreators(
{
onIncrement: incrementWithDelay,
},
dispatch
);
But that's not a shorthand syntax
Shorthand syntax is this:
connect(null, { onIncrement: incrementWithDelay })
Is there any reason you want to be able to use a return value of the dispatch call?
e.g.: props.incrementWithDelay().then(doSomethingElse)
This looks like a smell. But I think return value can be safely ignored.
So () => Action<void>
should be assignable to () => void
I've created a fix for typescript-fsa: https://github.com/aikoven/typescript-fsa/pull/82
Maybe you can use the same approach
Is there a solution for mapDispatchToProps shorthand syntax?
I'm getting this error:
Is there a way to fix it without changing prop types of MyComponent?