formik

Build forms in React, without the tears 😭

APACHE-2.0 License

Downloads
11.2M
Stars
33.5K
Committers
456

Bot releases are hidden (Show)

formik - v0.9.0-alpha.10

Published by jaredpalmer about 7 years ago

  • Fix incorrect prop-type on <Field />
formik - v0.8.9

Published by jaredpalmer about 7 years ago

Patch

  • #109 Fix bug is hoist statics (caused crash in RN)
  • Moved to TravisCI instead of CircleCI
formik - v0.8.8

Published by jaredpalmer about 7 years ago

Patch

  • #103 Fixes isValid logic when form is dirty
formik - v0.8.7

Published by jaredpalmer about 7 years ago

tl;dr

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)

formik - v0.8.6

Published by jaredpalmer about 7 years ago

Bugfix:

  • #100 Fixes double invocation of custom validate methods
formik - v0.8.5

Published by jaredpalmer about 7 years ago

  • Make sure status is reset when calling resetForm
formik - v0.8.3

Published by jaredpalmer about 7 years ago

Patch Release:

  • Don't use Object.values to compute the dirty prop.
formik - v0.8.2

Published by jaredpalmer about 7 years ago

Patch Release

  • #76 Fixes bug in hoist statics
formik - v0.8.0

Published by jaredpalmer about 7 years ago

tl;dr

  • No breaking changes, but a few deprecation warnings.
  • New names for some imperative setters
  • validationSchema and Yup are now 100% optional
  • New validate method can handle sync and async custom validators
  • More control over when validation is run

Deprecations (console warnings right now) 🗑

  • Deprecate handleChangeValue. Use setFieldValue instead.
  • Deprecate mapValuesToPayload. Move your function to the top of handleSubmit.
  • Deprecate setError escape hatch with warning. Use setStatus (it's identical and a better name IMHO).

New props and helpers 🍹 ⭐️ 🎉

  • setFieldValue: same as handleChangeValue() except it does not touch the field. Call setFieldTouched right after if you need to
  • setFieldTouched: 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)

New Formik configuration options ⚙️

  • 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.

Even more badass TypeScript support 🎉

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

formik - v0.7.2

Published by jaredpalmer over 7 years ago

Patch Release

  • #48 BUGFIX: ensure that handleBlur doesn't clobber entire touched state
formik - v0.7.1

Published by jaredpalmer over 7 years ago

  • Updated docs
  • Works with React 14, 15, and 16-alpha
  • Works with React Native (react-dom is no longer a peerDependency)
formik - v0.7.0

Published by jaredpalmer over 7 years ago

Changed Formik to a named export.

Old:

import Formik from 'formik';

New

import { Formik } from 'formik';
formik - v0.6.1

Published by jaredpalmer over 7 years ago

  • Drop defaults in generic types, NEW TypeScript Signatures:
    • Formik<Props, Values, Payload>
    • InjectedFormikProps<Props, Values>
    • FormikBag<Props, Values>
formik - v0.6.0

Published by jaredpalmer over 7 years ago

  • displayName is now optional. Formik will now showup as Formik(<ComponentName>) in React DevTools
  • Non-React static class properties of inner components are now preserved
  • Dropped recompose
  • TypeScript improvements:
    • FormikBag<Props> has become FormikBag<Props,Values>
    • InjectedFormikProps<Props> is the same as InjectedFormikProps<Props, Props>
Package Rankings
Top 0.27% on Npmjs.org
Top 3.35% on Proxy.golang.org
Badges
Extracted from project README
Stable Release Blazing Fast gzip size license Discord