@shopify/react-form-state
Manage react forms tersely and type-safe with no magic.
Last updated 17 days ago by shopify-dep .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @shopify/react-form-state 
SYNC missed versions from official npm registry.

@shopify/react-form-state

Build Status License: MIT npm version npm bundle size (minified + gzip)

Manage react forms tersely and safely-typed with no magic.

Installation

$ yarn add @shopify/react-form-state

Usage

<FormState />

The default component exported by this library is <FormState />.

import FormState from '@shopify/react-form-state';
// Fields here refers to the inferred type of your initialValues object
interface Props<Fields> {
  initialValues: Fields;
  validators?: Partial<ValidatorDictionary<Fields>>;
  onSubmit?: SubmitHandler<Fields>;
  validateOnSubmit?: boolean;
  children(form: FormDetails<Fields>): React.ReactNode;
}

Its only mandatory props are initialValues and children. The initialValues prop is used to infer all the types for the rest of the component, and to generate handlers and field state objects. The children prop expects a function of the current state of the form, which is represented by a FormDetails object.

<FormState initialValues={myInitialValues}>
  {({fields, dirty, valid, submitting, errors, reset, submit}) => {
    return /* some cool ui */;
  }}
</FormState>

For detailed explanations of how to use <FormState /> check out the guide.

validators

The library also makes a number of validation factory functions available out of the box that should help with common use cases, as well as some tools to make building reusable custom validators easy.

import {validate, validators} from '@shopify/react-form-state';

For detailed explanations of the validation utilities, check out the validation docs.

Current Tags

  • 0.11.16                                ...           latest (17 days ago)

67 Versions

  • 0.11.16                                ...           17 days ago
  • 0.11.15                                ...           23 days ago
  • 0.11.14                                ...           a month ago
  • 0.11.13                                ...           2 months ago
  • 0.11.12                                ...           2 months ago
  • 0.11.11                                ...           2 months ago
  • 0.11.10                                ...           3 months ago
  • 0.11.9                                ...           3 months ago
  • 0.11.8                                ...           3 months ago
  • 0.11.7                                ...           3 months ago
  • 0.11.6                                ...           4 months ago
  • 0.11.5                                ...           6 months ago
  • 0.11.4                                ...           6 months ago
  • 0.11.3                                ...           6 months ago
  • 0.11.2                                ...           7 months ago
  • 0.11.1                                ...           7 months ago
  • 0.11.0                                ...           7 months ago
  • 0.10.7                                ...           7 months ago
  • 0.10.6                                ...           7 months ago
  • 0.10.5                                ...           7 months ago
  • 0.10.4                                ...           7 months ago
  • 0.10.3                                ...           8 months ago
  • 0.10.2                                ...           8 months ago
  • 0.10.1                                ...           8 months ago
  • 0.10.0                                ...           8 months ago
  • 0.9.1                                ...           8 months ago
  • 0.9.0                                ...           9 months ago
  • 0.8.3                                ...           9 months ago
  • 0.8.2                                ...           9 months ago
  • 0.8.1                                ...           10 months ago
  • 0.8.0                                ...           10 months ago
  • 0.7.4                                ...           10 months ago
  • 0.7.3                                ...           10 months ago
  • 0.7.2                                ...           10 months ago
  • 0.7.1                                ...           a year ago
  • 0.7.0                                ...           a year ago
  • 0.6.0                                ...           a year ago
  • 0.5.6                                ...           a year ago
  • 0.5.4                                ...           a year ago
  • 0.5.3                                ...           a year ago
  • 0.5.2                                ...           a year ago
  • 0.5.1                                ...           a year ago
  • 0.5.0                                ...           a year ago
  • 0.4.3                                ...           a year ago
  • 0.4.2                                ...           a year ago
  • 0.4.0                                ...           a year ago
  • 0.3.4                                ...           a year ago
  • 0.3.3                                ...           a year ago
  • 0.3.2                                ...           a year ago
  • 0.3.1                                ...           a year ago
  • 0.2.9                                ...           a year ago
  • 0.2.8                                ...           a year ago
  • 0.2.7                                ...           a year ago
  • 0.2.6                                ...           a year ago
  • 0.2.5                                ...           a year ago
  • 0.2.4                                ...           a year ago
  • 0.2.3                                ...           a year ago
  • 0.2.2                                ...           a year ago
  • 0.2.1                                ...           a year ago
  • 0.2.0                                ...           a year ago
  • 0.1.9                                ...           a year ago
  • 0.1.7                                ...           a year ago
  • 0.1.6                                ...           a year ago
  • 0.1.5                                ...           a year ago
  • 0.1.4                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.0                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 112
Dependencies (3)
Dev Dependencies (3)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |