Skip to content

Commit d7e2af5

Browse files
committed
Docs improvements
1 parent 88a1acb commit d7e2af5

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

README.md

+36-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ const MyForm = () => {
8585
- [Simple Example](#simple-example)
8686
- [API](#api)
8787
- [`useField`](#usefield)
88+
- [`name : string`](#name--string)
89+
- [`form : Form`](#form--form)
90+
- [`validate? : (value:any) => any`](#validate--valueany--any)
91+
- [`subscription? : FieldSubscription`](#subscription--fieldsubscription)
8892
- [`useForm`](#useform)
93+
- [`onSubmit : (values:Object) => ?Object | Promise<?Object> | void`](#onsubmit--valuesobject--object--promiseobject--void)
94+
- [`validate?: (values:Object) => Object | Promise<Object>`](#validate-valuesobject--object--promiseobject)
8995
- [Contributors](#contributors)
9096
- [Backers](#backers)
9197
- [Sponsors](#sponsors)
@@ -102,14 +108,42 @@ Shows how to create fields and attach them to `<input/>` elements.
102108

103109
The following can be imported from `react-final-form-hooks`.
104110

105-
### `useField(name: string, form: Form, validate?: (value:any) => any, subscription: Object)`
111+
### `useField`
106112

107113
Returns an object similar to [`FieldRenderProps`](https://github.com/final-form/react-final-form#fieldrenderprops).
108114

109-
### `useForm(onSubmit: (values:Object) => Promise | void, validate: (values:Object) => Object)`
115+
`useField` takes four parameters:
116+
117+
#### `name : string`
118+
119+
> The name of the field. Required.
120+
121+
#### `form : Form`
122+
123+
> The object returned from `useForm`. Required.
124+
125+
#### `validate? : (value:any) => any`
126+
127+
> A field-level validation function that takes the current value and returns `undefined` if it is valid, or the error if it is not. Optional.
128+
129+
#### `subscription? : FieldSubscription`
130+
131+
> A subscription of which parts of field state to be notified about. See [`FieldSubscription`](https://github.com/final-form/final-form#fieldsubscription--string-boolean-). Optional.
132+
133+
### `useForm`
110134

111135
Returns an object similar to [`FormRenderProps`](https://github.com/final-form/react-final-form#formrenderprops).
112136

137+
`useForm` takes two parameters:
138+
139+
#### `onSubmit : (values:Object) => ?Object | Promise<?Object> | void`
140+
141+
See [🏁 Final Form's `onSubmit` docs](https://github.com/final-form/final-form#onsubmit-values-object-form-formapi-callback-errors-object--void--object--promiseobject--void) for more information. Required.
142+
143+
#### `validate?: (values:Object) => Object | Promise<Object>`
144+
145+
A record level validation function. See [🏁 Final Form's `validate` docs](https://github.com/final-form/final-form#validate-values-object--object--promiseobject) for more information. Optional.
146+
113147
---
114148

115149
## Contributors

0 commit comments

Comments
 (0)