Skip to content

Instantly share code, notes, and snippets.

@jaredpalmer
Last active September 19, 2017 19:01
Show Gist options
  • Save jaredpalmer/4d239783b487f47955af7eb810a208fe to your computer and use it in GitHub Desktop.
Save jaredpalmer/4d239783b487f47955af7eb810a208fe to your computer and use it in GitHub Desktop.
const Basic = () =>
<div>
<h1>My Form</h1>
<p>This can be anywhere in your application</p>
<Formik
initialValues={{ email: '', password: '' }}
validate={values => { /* omitted for brevity */ }}
onSubmit={values => { /* omitted for brevity */ }}
render={({ values, errors, touched, handleChange, handleSubmit, isSubmitting }) =>
<form onSubmit={handleSubmit}>
<input
type="email"
name="email"
onChange={handleChange}
value={values.email}
/>
{touched.email && errors.email && <div>{errors.email}</div>}
<input
type="password"
name="password"
onChange={handleChange}
value={values.password}
/>
{touched.password && errors.password && <div>{errors.password}</div>}
<button type="submit" disabled={isSubmitting}>Submit</button>
</form>}
/>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment