1const mapDispatchToProps = (dispatch) => {
2 return {
3 // dispatching plain actions
4 increment: () => dispatch({ type: 'INCREMENT' }),
5 decrement: () => dispatch({ type: 'DECREMENT' }),
6 reset: () => dispatch({ type: 'RESET' }),
7 }
8}
9
10⭐ Note: We recommend using the object form of
11mapDispatchToProps unless you specifically
12need to customize dispatching behavior in some way.
1
2function mapDispatchToProps(dispatch){
3return{submitNewMessage: function(add){
4 dispatch(addMessage(add))}
5 }
6}
7
1const mapDispatchToProps = (dispatch) => {
2 return {
3 onTodoClick: (id) => {
4 dispatch(toggleTodo(id))
5 }
6 }
7}