yarn formik 2.1.0

latest releases: 2.4.6, 2.4.5, 2.4.4...
4 years ago

Minor Changes

  • Add FieldHelpers object to the array returned by useField: #2124. This
    exposes three helper functions to allow you to imperatively change the
    field in question:

    1. setValue(value: any)
    2. setTouched(value: boolean)
    3. setError(value: string)

    Before

    const MyInput = (props) => {
     const formik = useFormikContext() 
     const [field, meta] = useField(props)
     const handleThing = () => {
        formik.setFieldValue(props.name, 'boop') 
     }
     // ...
    }

    After

    const MyInput = (props) => {
     const [field, meta, helpers] = useField(props)
     const handleThing = () => {
        helpers.setValue('boop') 
     }
     // ...
    }

Credits

Huge thanks to @drivasperez for helping!

Don't miss a new formik release

NewReleases is sending notifications on new releases.