mapdispatchtoprops with typescript code example
Example 1: mapdispatchtoprops
const mapDispatchToProps = (dispatch) => {
return {
increment: () => dispatch({ type: 'INCREMENT' }),
decrement: () => dispatch({ type: 'DECREMENT' }),
reset: () => dispatch({ type: 'RESET' }),
}
}
⭐ Note: We recommend using the object form of
mapDispatchToProps unless you specifically
need to customize dispatching behavior in some way.
Example 2: redux typescript mapdispatchtoprops
const mapDispatchToProps = (dispatch: ThunkDispatch<any, any, AnyAction>) => {
...