mapDispatchToProps: any point?

前端 未结 2 972
终归单人心
终归单人心 2021-02-07 07:12

I was wondering if there was still a point using mapDispatchToProps today. I\'m working on the redux documentation tutorials (to build a todo list) where Visi

2条回答
  •  囚心锁ツ
    2021-02-07 07:47

    connect() will automatically bind dispatch to your actions if they are passed in as an object of function names.

    So no, you don't need to implement mapStateToProps. Instead you can just pass you actions like this:

    export default connect((state) => state, {
      action1,
      action2,
    })(MyComponent);
    

提交回复
热议问题