Improvements 🔥
- Add new
<Field as>
prop that passes Formik input-related props straight through. - Add a new
meta
object to<Field children>
with field-level metadata.
Fixes 🐛
- Fix
enableReinitialize
regression from alpha.0
Deprecations ⚠️
- Deprecate
<Field render>
via warning. - Deprecate
<Field component>
via warning.
Breaking Change from alpha.0
🚨
- Changed the name of
meta.touch
tometa.touched
, wheremeta
is the second element of the tuple returned byuseField
.
import React from 'react';
import { useField } from 'formik';
const MyTextField = ({ label, ...props }) => {
const [field, meta] = useField(props.name);
return (
<>
<label>
{label}
<input {...field} {...props} />
</label>
- {meta.touch && meta.error ? (
+ {meta.touched && meta.error ? (
<div className="error">{meta.error}</div>
) : null}
</>
);
};