You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Afunction that creates a new `FormFactory<TFormData>` instance.
14
+
Afunction that creates a new `FormFactory<TFormData, TFormValidator>` instance.
15
15
16
16
-`opts`
17
-
-Optionalformoptionsanda`listen`function to be called with the form state.
17
+
-Optionalformoptions.
18
18
19
-
### `FormFactory<TFormData>`
19
+
### `FormFactory<TFormData, TFormValidator>`
20
20
21
21
Atyperepresenting a form factory. Form factories provide a type-safe way to interact with the form API as opposed to using the globally exported form utilities.
When using `@tanstack/react-form`, the [core field API](../../reference/fieldApi) is extended with additional methods for React-specific functionality:
8
+
When using `@tanstack/react-form`, the [core field API](../../reference/fieldApi) is extended at type level with additional methods for React-specific functionality:
Copy file name to clipboardExpand all lines: docs/framework/react/reference/formApi.md
+18-9Lines changed: 18 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,23 +3,32 @@ id: formApi
3
3
title: Form API
4
4
---
5
5
6
-
### `FormApi<TFormData>`
6
+
### `FormApi<TFormData, TFormValidator>`
7
7
8
-
When using `@tanstack/react-form`, the [core form API](../../reference/formApi) is extended with additional methods for React-specific functionality:
8
+
When using `@tanstack/react-form`, the [core form API](../../reference/formApi) is extended at type level with additional methods for React-specific functionality:
9
9
10
10
-```tsx
11
-
Field: FieldComponent<TFormData>
11
+
Provider: (props:PropsWithChildren) =>JSX.Element
12
12
```
13
-
- A pre-bound and type-safe field component, specific to this forms instance.
13
+
- React provider use to wrap your components. Reference React's [ContextProvider]("https://react.dev/reference/react/createContext#provider")
14
+
-```tsx
15
+
Field: FieldComponent<TFormData, TFormValidator>
16
+
```
17
+
- A React component to render form fields. With this, you can render and manage individual form fields.
14
18
-```tsx
15
19
useField: UseField<TFormData>
16
20
```
17
-
- A pre-bound and type-safe custom hook to use fields from this form instance.
21
+
- A custom React hook that provides functionalities related to individual form fields. It gives you access to field values, errors, and allows you to set or update field values.
A custom React Hook that returns an instance of the `FormApi` class.
12
17
This API encapsulates all the necessary functionalities related to the form. It allows you to manage form state, handle submissions, and interact with form fields
13
18
14
-
15
-
16
-
### `FormProps`
17
-
18
-
Anobjecttyperepresenting the form component props.
19
-
20
-
-Inheritsfrom`React.HTMLProps<HTMLFormElement>`.
21
-
-`children: React.ReactNode`
22
-
-Theform's child elements.
23
-
24
-
```tsx
25
-
onSubmit: (e: FormSubmitEvent) => void
26
-
```
27
-
-`onSubmit`function of type `FormSubmitEvent = React.FormEvent<HTMLFormElement>`
-a`useStore`hookthatconnectstotheinternalstoreoftheform. Itcanbeusedtoaccesstheform's current state or any other related state information. You can optionally pass in a selector function to cherry-pick specific parts of the state
-a`Subscribe`function that allows you to listen and react to changes in the form's state. It's especially useful when you need to execute side effects or render specific components in response to state updates.
0 commit comments