Created
January 6, 2019 17:23
-
-
Save converge/d5b2ddb243d08f364cbfed6f75497b08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import { Formik, Field, Form, ErrorMessage } from 'formik' | |
import './index.css' | |
class LoginForm extends Component { | |
handleSubmit = (values, actions) => { | |
actions.setSubmitting(true) | |
console.log(values) | |
console.log(actions) | |
// just login now without passwd: | |
const { history } = this.props | |
history.push('/dashboard') | |
} | |
render() { | |
return ( | |
<div> | |
<h1>Admin</h1> | |
<Formik | |
initialValues={{ | |
user: '', | |
passwd: '', | |
}} | |
validate={values => { | |
let errors = {} | |
}} | |
onSubmit={this.handleSubmit} | |
render={x => ( | |
<div className='login-form'> | |
<Form> | |
<div className='login-item'> | |
<Field name='user' type='text' placeholder='Username' /> | |
</div> | |
<div className='login-item'> | |
<Field name='passwd' type='password' placeholder='Password' /> | |
</div> | |
<div className='login-item'> | |
<button type='submit' disabled={x.isSubmitting}>Login</button> | |
</div> | |
</Form> | |
</div> | |
)} | |
/> | |
</div> | |
) | |
} | |
} | |
export default LoginForm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment