Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
79
rated 0 times [  83] [ 4]  / answers: 1 / hits: 46561  / 9 Years ago, thu, december 24, 2015, 12:00:00

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



handleSubmit(username, pass, nextPath) {
function redirect() {
this.props.pushState(null, nextPath);
}
this.props.login(username, pass, redirect); //action from LoginAcitons
}


username and pass arrived from dumb-component.



Smart component connect



function mapStateToProps(state) {
return {
user: state.app.user
};
}

function mapDispatchToProps(dispatch) {
return bindActionCreators(LoginActions, dispatch)
}


How I can add pushState from redux-router ? Or I'm on wrong way?



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

More From » reactjs

 Answers
12
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);

[#63955] Tuesday, December 22, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bruno

Total Points: 602
Total Questions: 100
Total Answers: 111

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
;