Skip to content

Instantly share code, notes, and snippets.

@jaredpalmer
Last active September 19, 2017 19:01
Show Gist options
  • Save jaredpalmer/f312250ebd585a8cbdd08f3391433d79 to your computer and use it in GitHub Desktop.
Save jaredpalmer/f312250ebd585a8cbdd08f3391433d79 to your computer and use it in GitHub Desktop.
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