Last active
September 19, 2017 19:01
-
-
Save jaredpalmer/f312250ebd585a8cbdd08f3391433d79 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 from 'react' | |
import { Formik, Field, Form } from 'formik' | |
const App = () => | |
<div> | |
<h1>My Login Form</h1> | |
<p>This can be anywhere in your application</p> | |
<Formik | |
initialValues={{ email: '', password: '', favorite: 'Kirk' }} | |
validate={values => { /* omitted for brevity */ }} | |
onSubmit={values => { /* omitted for brevity */ }} | |
render={({ errors, touched, isSubmitting }) => | |
<Form className="whatevs"> | |
<Field name="email" type="email" /> | |
{touched.email && errors.email && <div>{errors.email}</div>} | |
<Field name="password" type="password" /> | |
{touched.password && errors.password && <div>{errors.password}</div>} | |
<button type="submit" disabled={isSubmitting}>Submit</button> | |
</Form>} | |
/> | |
</div> | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment