Created
February 19, 2018 13:04
-
-
Save iamdanthedev/c80faaa1707c8693f6aacfb7e6b5307d to your computer and use it in GitHub Desktop.
Revisions
-
iamdanthedev created this gist
Feb 19, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ const initialValues = { comment: 'hello'; } storiesOf('Form Controls: Select', module) .addDecorator(withFormValues(initialValues) .add('default', () => ( <Select name="select" label="Country..." options={selectOptions} /> </Formik> )) 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ import React from 'react'; import { Formik } from 'formik'; /** * Decorates a story with Formik * @param initialValues * @param validationSchema - yup schema (formik validationSchema) * @returns {function(*): *} */ export const withFormValues = (initialValues, validationSchema) => story => ( <Formik initialValues={initialValues} validationSchema={validationSchema} onSubmit={values => console.log(values)} > {story()} </Formik> );