How use react-redux connect with mapStateToProps,MapDispatchToProps and redux-router

前端 未结 2 526
既然无缘
既然无缘 2021-01-31 17:05

I want to use in my container \"LoginPage\" (smart-component) redirect after login. Something like this:

handleSubmit(username, pass, nextPath) {
    function re         


        
2条回答
  •  误落风尘
    2021-01-31 17:42

    function mapStateToProps(state) {
      return {
        user: state.app.user
      };
    }
    
    function mapDispatchToProps(dispatch) {
      return {
        actions: bindActionCreators(LoginActions, dispatch),
        routerActions: bindActionCreators({pushState}, dispatch)
      }
    }
    
    export default connect(mapStateToProps, mapDispatchToProps)(LoginPage);
    

提交回复
热议问题