score:1

Accepted answer
class LoginX extends React.Component {
    constructor(props) {
        super(props);
        this.state = { login: '', password: '' };      
    }
    handleChange = (e) => {
        this.setState({
            [e.currentTarget.name]: e.currentTarget.value,
        });
    }
    onClick = (e) => {
        const { login, password } = this.state;
        e.preventDefault();
        this.props.onSubmit({ login, password });
    }
    render() {
        ...
        <button onClick={this.onClick}>submit</button>
    }
}


const mapStateToProps = (state) => {
    return state;
}
const mapDispatchToProps = (dispatch) => {
    return {
        onSubmit: (credentials) => {
            console.log('dispatch');
            dispatch({
                type: 'LOGIN_SUBMIT',
                payload: {
                    token: credentials
                }
            })
        }
    }
};

let Login = connect(mapStateToProps, mapDispatchToProps)(LoginX);

export default Login;

Related Query

More Query from same tag