I am writing a simple React + Redux Container Component. Given below is the code
export default class LoginContainerComponent extends React.Component {
constructor() {
super();
connect( this.mapStateToProps, this.mapDispatchToProps )( LoginComponent )
}
render() {
return (<LoginComponent></LoginComponent>);
}
mapStateToProps( state ) {
return {
loginText: 'Login'
,
registerText: 'Register'
}
}
mapDispatchToProps( dispatch ) {
return {
onLoginClick: () => {
alert( 'login clicked' );
},
onRegisterClick: () => {
alert( 'register clicked' );
}
}
};
}
I have a few questions surrounding this 1. Is this overall approach correct, specifically where I define the connect( in the constructor? A lot of the examples I have seen define connect outside the component, but if I define this outside the component then I do not have access to mapStateToPrope, and mapDispatchToProps which I think should be inside the component.