Build forms in React, without the tears 😭
APACHE-2.0 License
Bot releases are hidden (Show)
Published by jaredpalmer about 7 years ago
<Field />
Published by jaredpalmer about 7 years ago
Published by jaredpalmer about 7 years ago
isValid
logic when form is dirty
Published by jaredpalmer about 7 years ago
validationSchema
can now alternatively accept a function that returns a Yup schema (instead of just a schema)
Old:
validationSchema?: Schema
New:
validationSchema?: Schema | ((props: Props) => Schema)
Published by jaredpalmer about 7 years ago
Bugfix:
Published by jaredpalmer about 7 years ago
status
is reset when calling resetForm
Published by jaredpalmer about 7 years ago
Patch Release:
Object.values
to compute the dirty
prop.Published by jaredpalmer about 7 years ago
Published by jaredpalmer about 7 years ago
validationSchema
and Yup are now 100% optionalvalidate
method can handle sync and async custom validatorshandleChangeValue
. Use setFieldValue
instead.mapValuesToPayload
. Move your function to the top of handleSubmit
.setError
escape hatch with warning. Use setStatus
(it's identical and a better name IMHO).setFieldValue
: same as handleChangeValue()
except it does not touch the field. Call setFieldTouched
right after if you need tosetFieldTouched
: parallel to setFieldValue
, but for touched
setFieldError:
...yeah same thing but for errors
submitForm: () => void;
which lets you submit your form without a dom event (very useful for testing). s/o @ctrlplusb for seeing this as missing way before I did.dirty: boolean
as computed prop. true
if anything has been touched.status?: any
& setStatus: (status: any) => void
An escape hatch helper for when you need to set arbitrary state (like a success behavior)validate?: (values: Values, props: Props) => { [field: string]: string } | Promise<any>
Optional custom validation option. Either return an errors
object or and Promise that throws an error
object.
validateOnChange?: boolean = false
. Will fire off validation on change events.
validateOnBlur?: boolean = true
. Will fire off validation on blur events.
moar tests! (like a lot lot lot more)
validationSchema
is now optional.
See #74 for details.
I added type safety to all the new setters by restricting their respective keys to Values
by using mapped types. As a result, instead of being able to set arbitrary keys on errors
and touched
, all the setters will now get angry if field(s) are not found in your Values
interface.
Old
interface FormikValues {
[field: string]: any;
}
interface FormikErrors {
[field: string]: string;
}
interface FormikTouched {
[field: string]: boolean;
}
New
export interface FormikValues {
[field: string]: any;
}
export type FormikErrors<Values extends FormikValues> = {
[Key in keyof Values]?: string
};
export type FormikTouched<Values extends FormikValues> = {
[Key in keyof Values]?: boolean
};
-Jared
Published by jaredpalmer over 7 years ago
Published by jaredpalmer over 7 years ago
react-dom
is no longer a peerDependency
)Published by jaredpalmer over 7 years ago
Changed Formik to a named export.
Old:
import Formik from 'formik';
New
import { Formik } from 'formik';
Published by jaredpalmer over 7 years ago
Formik<Props, Values, Payload>
InjectedFormikProps<Props, Values>
FormikBag<Props, Values>
Published by jaredpalmer over 7 years ago
displayName
is now optional. Formik will now showup as Formik(<ComponentName>)
in React DevToolsrecompose
FormikBag<Props>
has become FormikBag<Props,Values>
InjectedFormikProps<Props>
is the same as InjectedFormikProps<Props, Props>