1.0.0 • Published 5 years ago

formik-office-ui-fabric-react v1.0.0

Weekly downloads
471
License
MIT
Repository
github
Last release
5 years ago

npm version Build Status Coverage Status npm code style: prettier

formik-office-ui-fabric-react

💉 Instant pain reliever for using Formik with Office UI Fabric React 💉

Why?

To reduce the boilerplate code needed to get Fabrics input components work seamlessly with Formiks field props and validation errors.

How?

  1. Install package
yarn add formik-office-ui-fabric-react
# or
npm install --save formik-office-ui-fabric-react
  1. Replace FooComponent with FormikFooComponent or use the mapFieldToFooComponent, i.e
import { Formik, Form, Field } from 'formik'
import { DatePicker } from 'office-ui-fabric-react'
import { FormikDatePicker, mapFieldToDatePicker } from 'formik-office-ui-fabric-react'

const OldAndUgly = () => (
  <Formik initialValues={{ date: new Date() }}>
    <Form>
      <Field
        name="date"
        render={fieldProps => (
          <DatePicker
            value={/* wrapper code for fieldProps.value */}
            onSelectDate={/* wrapper code for fieldProps.onChange */}
            {/* and more ugly wrapper code trying to get name, onBlur, etc. working */}
          />
        )}
      />
    </Form>
  </Formik>
)

// using the component
const NewAndPretty = () => (
  <Formik initialValues={{ date: new Date() }}>
    <Form>
      <Field name="date" component={FormikDatePicker} />
    </Form>
  </Formik>
)

// or using the map function
const NewAndAlsoPretty = () => (
  <Formik initialValues={{ date: new Date() }}>
    <Form>
      <Field name="date" render={fieldProps => (
        <DatePicker {...mapFieldToDatePicker(fieldProps)} />
      )} />
    </Form>
  </Formik>
)

Documentation

Development

git clone https://github.com/kmees/formik-office-ui-fabric-react
cd formik-office-ui-fabric-react && yarn install

Running development server

yarn start

Running tests

yarn test
1.0.0

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.0

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago