kazagkazag
7/14/2016 - 5:32 AM

react-13.jsx

/*
import {connect} from "react-redux";
import * as actions from "./actions";
import LoginForm from "./components/LoginForm";
*/

export class Login extends Component {

    render() {
        return (
            <LoginForm
                onLogin={this.props.authenticate}
                isAuthenticated={this.props.isAuthenticated}
            />
        );
    }
}

export const mapStateToProps = (state) => {
    return {
        isAuthenticated: state.authentication.isAuthenticated
    }
};

export const mapDispatchToProps = (dispatch) => {
    return {
        authenticate: () => {
            dispatch(actions.authenticate())
        }
    }
};

Login.propTypes = {
    authenticate: PropTypes.func,
    isAuthenticated: PropTypes.bool.isRequired
};

export default connect(
    mapStateToProps,
    mapDispatchToProps
)(Login);