【发布时间】:2015-12-24 09:25:57
【问题描述】:
我想在登录后在我的容器中使用“LoginPage”(智能组件)重定向。 像这样的:
handleSubmit(username, pass, nextPath) {
function redirect() {
this.props.pushState(null, nextPath);
}
this.props.login(username, pass, redirect); //action from LoginAcitons
}
用户名和密码来自哑组件。
智能组件连接
function mapStateToProps(state) {
return {
user: state.app.user
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(LoginActions, dispatch)
}
如何从 redux-router 添加 pushState ?还是我走错路了?
export default connect(mapStateToProps, {pushState})(LoginPage); //works, but haven't actions
export default connect(mapStateToProps, mapDispatchToProps)(LoginPage); //works, but haven't pushState
export default connect(mapStateToProps, mapDispatchToProps, {pushState})(LoginPage); //Uncaught TypeError: finalMergeProps is not a function
【问题讨论】:
-
我遇到了类似的问题。
LoginActions这里是什么? -
为什么这需要在组件本身中完成?只是好奇。
标签: javascript reactjs redux