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/advanced/Array-fields.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,18 +6,18 @@ title: Array fields
6
6
7
7
# Array fields
8
8
9
-
To create dynamic array fields, you should use the [`ArrayForm`](/typed-react-form/reference/ArrayForm) component or [`useArrayForm`](/typed-react-form/useArrayForm) hook. These are wrappers around [`useObjectField`](/typed-react-form/reference/useObjectField) which provide useful functions and optimizations for arrays.
9
+
To create dynamic array fields, you should use the [`ArrayField`](/typed-react-form/reference/ArrayField) component or [`useArrayField`](/typed-react-form/useArrayField) hook. These are wrappers around [`useObjectField`](/typed-react-form/reference/useObjectField) which provide useful functions and optimizations for arrays.
If you have an array field with a constant size, you should probably just use [`ObjectField`](/typed-react-form/reference/ObjectField). (See bottom for examples)
15
15
16
16
**Note on keys**: you **should** use the index as key, this seems against nature at first, but remember that this library does not rerender each time something in the array changes. When 2 array items get swapped, it does not rerender either, only when the array size changes, it rerenders. For this reason, it is not a problem (and it's recommended) to use index as the key. (This can change in the future)
17
17
18
18
## Dynamic array examples
19
19
20
-
✔️ **Dynamic string array field using `ArrayForm`**
20
+
✔️ **Dynamic string array field using `ArrayField`**
21
21
22
22
```tsx
23
23
function NotesList() {
@@ -31,7 +31,7 @@ function NotesList() {
31
31
console.log("submit", form.values);
32
32
}}
33
33
>
34
-
<ArrayForm
34
+
<ArrayField
35
35
form={form}
36
36
name="notes"
37
37
render={({ form, values, append, remove }) => (
@@ -57,7 +57,7 @@ function NotesList() {
57
57
}
58
58
```
59
59
60
-
✔️ **Dynamic object array field using `ArrayForm`**
60
+
✔️ **Dynamic object array field using `ArrayField`**
61
61
62
62
Remember: this is all type checked!
63
63
@@ -80,7 +80,7 @@ function ShoppingListForm() {
80
80
81
81
{/* Create an array child form for the 'items' field */}
82
82
<h2>Items</h2>
83
-
<ArrayForm
83
+
<ArrayField
84
84
form={form}
85
85
name="items"
86
86
render={({ form, values, append, remove }) => (
@@ -119,7 +119,7 @@ function ShoppingListForm() {
119
119
}
120
120
```
121
121
122
-
✔️ **Dynamic object array field with seperate component for each child form and using `useArrayForm`**
122
+
✔️ **Dynamic object array field with seperate component for each child form and using `useArrayField`**
123
123
124
124
```tsx
125
125
interfaceShoppingListItem {
@@ -156,7 +156,7 @@ function ShoppingListForm() {
156
156
}
157
157
158
158
function ShoppingListItemsForm(props: { parent:FormState<ShoppingList> }) {
Copy file name to clipboardExpand all lines: docs/advanced/Object-fields.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,16 @@ title: Object fields
6
6
7
7
# Object fields
8
8
9
-
To be able to create inputs for fields in objects, child form are used. You can create child forms using the `ChildForm` component or `useChildForm` hook.
9
+
To be able to create inputs for fields in objects, child form are used. You can create child forms using the `ObjectField` component or `useObjectField` hook.
Copy file name to clipboardExpand all lines: docs/advanced/Toggling-a-field.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ function ToggleForm() {
55
55
56
56
{/* Use the setNullOnUncheck prop. The value prop contains the value that is set when the box gets checked again, you can omit it to use the default value */}
Copy file name to clipboardExpand all lines: docs/reference/ArrayForm.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
2
layout: default
3
3
parent: Reference
4
-
title: ArrayForm component
4
+
title: ArrayField component
5
5
---
6
6
7
-
# `<ArrayForm />`
7
+
# `<ArrayField />`
8
8
9
-
A component that provides array manipulation functions and optimizations. This is a wrapper around [`useArrayForm`](/typed-react-form/reference/useArrayForm). The only difference is that this component does not render its content when the array is null/undefined ([is togglable](/typed-react-form/advanced/Toggling-a-field)).
9
+
A component that provides array manipulation functions and optimizations. This is a wrapper around [`useArrayField`](/typed-react-form/reference/useArrayField). The only difference is that this component does not render its content when the array is null/undefined ([is togglable](/typed-react-form/advanced/Toggling-a-field)).
Copy file name to clipboardExpand all lines: docs/reference/ChildForm.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
2
layout: default
3
3
parent: Reference
4
-
title: ChildForm component
4
+
title: ObjectField component
5
5
---
6
6
7
7
# `<ObjectField />`
8
8
9
-
Use the `ChildForm` component if you want to make fields inside an object field available to inputs. This is a wrapper around [`useChildForm`](/typed-react-form/reference/useChildForm).
9
+
Use the `ObjectField` component if you want to make fields inside an object field available to inputs. This is a wrapper around [`useObjectField`](/typed-react-form/reference/useObjectField).
10
10
11
11
## Props
12
12
@@ -24,6 +24,6 @@ A function that renders, and creates inputs for the child form, which is passed
24
24
25
25
## Advanced
26
26
27
-
You can also use this component on array fields (index as name), but [`ArrayForm`](/typed-react-form/reference/ArrayForm) or [`useArrayForm`](/typed-react-form/reference/useArrayForm) is preferred when you want to create [dynamic array fields](/typed-react-form/advanced/Array-fields). It provides useful array manipulation functions and optimizations.
27
+
You can also use this component on array fields (index as name), but [`ArrayField`](/typed-react-form/reference/ArrayField) or [`useArrayField`](/typed-react-form/reference/useArrayField) is preferred when you want to create [dynamic array fields](/typed-react-form/advanced/Array-fields). It provides useful array manipulation functions and optimizations.
28
28
29
29
This component does not render its content when the form is empty (happens when its parent field has been assigned `null`, `undefined` or `{}`).
Copy file name to clipboardExpand all lines: docs/reference/FormState.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ title: FormState class
6
6
7
7
# `FormState`
8
8
9
-
The `FormState` class contains all the state of a form. This includes values, default values, errors, dirty flags and form state. You should always use the `useForm` or `useChildForm` hooks to create an instance of this class.
9
+
The `FormState` class contains all the state of a form. This includes values, default values, errors, dirty flags and form state. You should always use the `useForm` or `useObjectField` hooks to create an instance of this class.
10
10
11
11
This class provides a lot of useful functions to manipulate form values and state.
Copy file name to clipboardExpand all lines: docs/reference/useArrayForm.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
---
2
2
layout: default
3
3
parent: Reference
4
-
title: useArrayForm hook
4
+
title: useArrayField hook
5
5
---
6
6
7
-
# `useArrayForm`
7
+
# `useArrayField`
8
8
9
-
A hook that provides array manipulation functions and optimizations for an array field. This is the array-optimized version of [`useChildform`](/typed-react-form/reference/useChildForm). This hook only causes a rerender when the array size changes (this is why `values.map((e) => ...)` works when adding/removing a value).
9
+
A hook that provides array manipulation functions and optimizations for an array field. This is the array-optimized version of [`useObjectField`](/typed-react-form/reference/useObjectField). This hook only causes a rerender when the array size changes (this is why `values.map((e) => ...)` works when adding/removing a value).
10
10
11
11
This hook must be called, unconditionally, at the start of your component, just like the normal React hooks.
12
12
13
-
**If your array field can/will be null or undefined**, you should use the [`ArrayForm`](/typed-react-form/reference/ArrayForm) component instead, which does not render when the array is null/undefined.
13
+
**If your array field can/will be null or undefined**, you should use the [`ArrayField`](/typed-react-form/reference/ArrayField) component instead, which does not render when the array is null/undefined.
Copy file name to clipboardExpand all lines: docs/reference/useChildForm.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
---
2
2
layout: default
3
3
parent: Reference
4
-
title: useChildForm hook
4
+
title: useObjectField hook
5
5
---
6
6
7
-
# `useChildForm`
7
+
# `useObjectField`
8
8
9
9
Creates a form based on another form's field. Use this with nested objects. This hook does not cause a rerender.
10
10
11
11
This hook must be called, unconditionally, at the start of your component, just like the normal React hooks.
12
12
13
-
**If your field can/will be null or undefined**, you should use the [`ChildForm`](/typed-react-form/reference/ChildForm) component instead, which does not render when the field is null/undefined.
13
+
**If your field can/will be null or undefined**, you should use the [`ObjectField`](/typed-react-form/reference/ObjectField) component instead, which does not render when the field is null/undefined.
0 commit comments