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
Copy file name to clipboardExpand all lines: docs/reference/FormError.md
+13-23Lines changed: 13 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@ layout: default
3
3
parent: Reference
4
4
---
5
5
6
-
# `<FormError />`
6
+
# `<FieldError />`
7
7
8
-
A very simple field error component.
8
+
This component renders an error for a specific form field.
9
9
10
10
```tsx
11
11
const form =useForm(
@@ -17,28 +17,18 @@ const form = useForm(
17
17
18
18
<Fieldform={form}name="name" />
19
19
20
-
// Will render a `p` element on error.
21
-
<FormErrorform={form}name="name" />
22
-
```
23
-
24
-
## Custom error component
25
-
26
-
Because this component doesn't have a lot of functionality (only props are `form` and `name`), it is recommended to create a FormError component yourself.
27
-
28
-
Below is an example of a custom form error component.
20
+
// Will render a `React.Fragment` (plain text) element on error.
21
+
<FieldErrorform={form}name="name" />
29
22
30
-
```tsx
31
-
// Use generics to create type-safe code
32
-
function CustomFormError<T>(props: { form:FormState<T>; name:keyofT }) {
33
-
// Listen for changes on a form field, behaves like useState
0 commit comments