login.js 704 B

123456789101112131415161718192021
  1. import {connect} from "react-redux";
  2. import {useState} from "react";
  3. import {actionFullLogin} from "../../actions";
  4. const LoginForm = ({onLogin, history}) => {
  5. const [l, setL] = useState ('')
  6. const [p, setP] = useState ('')
  7. return (
  8. <div className='LoginColumn'>
  9. <input placeholder='Введите имя' onChange={e => setL(e.target.value)}></input>
  10. <input type='password' placeholder='Введите пароль' onChange={e => setP(e.target.value)}></input>
  11. <button onClick={() => {onLogin(l,p); history.push('/')}}>Войти</button>
  12. </div>
  13. )
  14. }
  15. export const CLoginForm = connect (null,{onLogin: actionFullLogin})(LoginForm)