Skip to content

Instantly share code, notes, and snippets.

@bengrunfeld
Last active September 8, 2020 14:59
Show Gist options
  • Save bengrunfeld/d912ac552d5e0d743523dfe5e9555828 to your computer and use it in GitHub Desktop.
Save bengrunfeld/d912ac552d5e0d743523dfe5e9555828 to your computer and use it in GitHub Desktop.
Combine Formik with TypeScript and React-Select
const schema = Yup.object({
dogBreed: Yup.string().required("Required")
})
const options = [
{ value: "terrier", label: "Terrier" },
{ value: "hound", label: "Hound" },
{ value: "corgie", label: "Corgie" },
];
<Formik
initialValues={{ ...initialValues }}
validationSchema={schema}
onSubmit={(values, { setSubmitting }) => {
console.log("-->> Success: ", values);
setSubmitting(false);
}}
>
<Form>
<DropDown
label="What is your dogs breed?"
name="dogBreed"
options={options}
iid="dogBreed"
/>
</Form>
</Formik>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment