Skip to content

Commit 3733bb9

Browse files
authored
Merge 6635f6d into a804807
2 parents a804807 + 6635f6d commit 3733bb9

File tree

1 file changed

+8
-33
lines changed

1 file changed

+8
-33
lines changed

README.md

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A 2kb library for building forms and validation with uncontrolled fields in Reac
77
[![Coverage Status](https://coveralls.io/repos/github/ericvaladas/react-uncontrolled-form/badge.svg?branch=master)](https://coveralls.io/github/ericvaladas/react-uncontrolled-form?branch=master)
88
[![Dependency Status](https://david-dm.org/ericvaladas/react-uncontrolled-form.svg)](https://david-dm.org/ericvaladas/react-uncontrolled-form)
99
[![devDependency Status](https://david-dm.org/ericvaladas/react-uncontrolled-form/dev-status.svg)](https://david-dm.org/ericvaladas/react-uncontrolled-form?type=dev)
10-
[![gzip size](http://img.badgesize.io/https://unpkg.com/react-uncontrolled-form/dist/react-uncontrolled-form.min.js?compression=gzip)](https://unpkg.com/react-uncontrolled-form/dist/react-uncontrolled-form.min.js)
10+
[![gzip size](http://img.badgesize.io/https://unpkg.com/react-uncontrolled-form/dist/react-uncontrolled-form.min.js?compression=gzip&label=gzip)](https://unpkg.com/react-uncontrolled-form/dist/react-uncontrolled-form.min.js)
1111

1212
## Usage
1313

@@ -198,41 +198,16 @@ class MyForm extends React.Component {
198198
}
199199
```
200200

201-
## API
202-
### Form
203-
You can obtain a `Form` instance by adding a `ref` prop to your form.
204-
```js
205-
render() {
206-
return (
207-
<Form ref={(form) => { this.form = form; }}>
208-
...
209-
</Form>
210-
);
211-
}
212-
```
213-
| Property | Type | Returns | Description |
214-
| --- | --- | --- | --- |
215-
| `fields` | `object` | `object` | `{fieldName: [field, ...], ...}` |
216-
| `getCheckboxValues(fieldName)` | `function` | `Array` | An array of field values |
217-
| `getField(fieldName)` | `function` | `Field instance` | The most recently changed field for the given name |
218-
| `handleSubmit(e)` | `function` | `Promise` | Calls `validate` then calls `props.onSubmit` |
219-
| `invalidFields` | `object` | `object` | `{fieldName: field, ...}` |
220-
| `validate()` | `function` | `Promise` | Calls `validate` on all fields |
221-
| `values()` | `function` | `object` | `{fieldName: fieldValue, ...}` |
201+
202+
### Form Props
222203

223204
| Prop | Description |
224205
| --- | --- |
225-
| [`onSubmit`](#form-submission) | Passes an additional form object argument to your handler<br>`onSubmit({valid: [bool], values: {...}, invalidFields: {...}}` |
226-
| [`values`](#initial-values) | An object that contains values for the form's fields |
227-
| [`messages`](#validation) | An object that contains messages for the form's fields |
228-
229-
### Field
230-
These properties are passed down to your field via props.
206+
| [`onSubmit`](#form-submission) | A callback function<br>`onSubmit({valid: [bool], values: {...}, invalidFields: {...}}` |
207+
| [`values`](#initial-values) | An object that will provide values to the form's fields |
208+
| [`messages`](#validation) | An object that will provide messages to the form's fields |
231209

232-
| Property | Type | Returns | Description |
233-
| --- | --- | --- | --- |
234-
| `handleChange(e)` | `function` | `Promise` | Sets the `value` property of the state |
235-
| `validate()` | `function` | `boolean` | Calls each validator and sets the `valid` and `message` properties of the state |
210+
### Field Props
236211

237212
| Prop | Description |
238213
| --- | --- |
@@ -243,7 +218,7 @@ These properties are passed down to your field via props.
243218
| `message` | The message returned by a validator or a form's `messages` prop |
244219
| `valid` | The valid property in the field's state. The initial value is `true` |
245220
| `validate` | The field's `validate` function |
246-
| `validators` | An array of validators |
221+
| `validators` | An array containing the field's [validators](#validators) |
247222
| `value` | The value property in the field's state |
248223

249224
**Note: `name` is a required prop that you must pass to your field as it is the lookup key for the field's value.**

0 commit comments

Comments
 (0)