Skip to content

Commit 82cf424

Browse files
committed
chore: updated docs removed mentioning the types and tried to explain what they do instead
1 parent 5ec7668 commit 82cf424

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

docs/reference/formApi.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ An object representing the options for a form.
2020
- ```tsx
2121
defaultValues?: TData
2222
```
23-
- The default values for the form fields.
23+
- Set initial values for you form.
2424
- ```tsx
2525
defaultState?: Partial<FormState<TData>>
2626
```
@@ -29,16 +29,16 @@ An object representing the options for a form.
2929
- ```tsx
3030
asyncDebounceMs?: number
3131
```
32-
- Optional time in milliseconds
32+
- Optional time in milliseconds if you want to introduce a delay before firing off an async action.
3333

3434
- ```tsx
3535
onMount?: (values: TData, formApi: FormApi<TData>) => ValidationError
3636
```
37-
- Optional function that takes values of `TData` and a formApi that is a generic of `FormApi<TData>` return a `ValidationError`
37+
- Optional function that fires as soon as the component mounts.
3838
- ```tsx
3939
onMountAsync?: ( values: TData, formApi: FormApi<TData>) => ValidationError | Promise<ValidationError>
4040
```
41-
- Optional async function that takes values of `TData` and a formApi that is a generic of `FormApi<TData>` return a `ValidationError` or a `Promise<ValidationError`
41+
- Optional async function that fires when the component mounts
4242
- ```tsx
4343
onMountAsyncDebounceMs?: number
4444
```
@@ -47,12 +47,12 @@ An object representing the options for a form.
4747
- ```tsx
4848
onChange?: (values: TData, formApi: FormApi<TData>) => ValidationError
4949
```
50-
- Optional function that takes values of `TData` and a formApi that is a generic of `FormApi<TData>` return a `ValidationError`
50+
- Optional function that checks the validity of your data whenever a value changes
5151

5252
- ```tsx
5353
onChangeAsync?: (values: TData, formApi: FormApi<TData>) => ValidationError | Promise<ValidationError>
5454
```
55-
- Optional onChange async function that takes values of `TData` and a formApi that is a generic of `FormApi<TData>` return a `ValidationError` or a `Promise<ValidationError`
55+
- Optional onChange asynchronous counterpart to onChange. Useful for more complex validation logic that might involve server requests.
5656

5757
- ```tsx
5858
onChangeAsyncDebounceMs?: number
@@ -62,12 +62,12 @@ An object representing the options for a form.
6262
- ```tsx
6363
onBlur?: (values: TData, formApi: FormApi<TData>) => ValidationError
6464
```
65-
- Optional function that takes values of `TData` and a formApi that is a generic of `FormApi<TData>` return a `ValidationError`
65+
- Optional function that validates the form data when a field loses focus, returns a `ValidationError`
6666

6767
- ```tsx
6868
onBlurAsync?: (values: TData,formApi: FormApi<TData>) => ValidationError | Promise<ValidationError>
6969
```
70-
- Optional onBlur async function that takes values of `TData` and a formApi that is a generic of `FormApi<TData>` return a `ValidationError` or a promise of `Promise<ValidationError>`
70+
- Optional onBlur asynchronous validation method for when a field loses focus return a `ValidationError` or a promise of `Promise<ValidationError>`
7171

7272
- ```tsx
7373
onBlurAsyncDebounceMs?: number
@@ -77,12 +77,13 @@ An object representing the options for a form.
7777
- ```tsx
7878
onSubmit?: (values: TData, formApi: FormApi<TData>) => any | Promise<any>
7979
```
80-
- A function to be called when the form is submitted and valid takes values of `TData` formApi of `FormApi<TData>` and returns `any` or a promise `Promise<any>`
80+
- A function to be called when the form is submitted, what should happen once the user submits a valid form returns `any` or a promise `Promise<any>`
8181

8282
- ```tsx
8383
onSubmitInvalid?: (values: TData, formApi: FormApi<TData>) => void
8484
```
85-
- A function to be called when the form is submitted but invalid.
85+
- Specify an action for scenarios where the user tries to submit an invalid form.
86+
8687

8788
### `FormApi<TFormData>`
8889

@@ -97,7 +98,7 @@ A class representing the Form API. It handles the logic and interactions with th
9798
- ```tsx
9899
store: Store<FormState<TFormData>>
99100
```
100-
- The internal store for the form state.
101+
- An internal mechanism that keeps track of the form's state.
101102
- ```tsx
102103
state: FormState<TFormData>
103104
```

0 commit comments

Comments
 (0)