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: src/content/docs/useform/register.mdx
+14-18Lines changed: 14 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,32 +102,28 @@ By selecting the register option, the API table below will get updated.
102
102
103
103
<ul>
104
104
<li>
105
-
Name is **required** and **unique** (except native radio and checkbox).
106
-
Input name supports both dot and bracket syntax, which allows you to easily
107
-
create nested form fields.
105
+
<strong>Name</strong> is <strong>required</strong> and must be <strong>unique</strong>
106
+
(except for native radio and checkbox inputs).
108
107
</li>
109
108
<li>
110
-
Name can neither start with a number nor use number as key name. Please
111
-
avoid special characters as well.
112
-
</li>
113
-
<li>
114
-
We are using dot syntax only for typescript usage consistency, so bracket `[]`
115
-
will not work for array form value.
116
-
109
+
Name must not start with a number or use numbers as standalone keys, and should avoid special characters.
110
+
For TypeScript consistency, only dot syntax is supported—bracket syntax (<code>[]</code>) will not work for array form values.
111
+
117
112
```javascript
118
-
register('test.0.firstName'); // ✅
119
-
register('test[0]firstName'); // ❌
113
+
register('test.0.firstName'); // ✅
114
+
register('test[0].firstName'); // ❌
120
115
```
121
-
122
116
</li>
123
117
124
-
<li>Disabled input will result in an undefined form value. If you want to prevent users from updating the input, you can use `readOnly` or `disable` the entire `fieldset`. Here is an [example](https://codesandbox.io/s/react-hook-form-disabled-inputs-oihxx).</li>
125
-
126
-
<li>To produce an array of fields, input names should be followed by a dot and number. For example: `test.0.data`</li>
118
+
<li>Disabled inputs return <code>undefined</code> as their form value.
119
+
If you need to prevent user edits while preserving the value, use
120
+
<code>readOnly</code> or disable the entire <code>fieldset</code>. Here is an [example](https://codesandbox.io/s/react-hook-form-disabled-inputs-oihxx).</li>
127
121
128
-
<li>Changing the name on each render will result in new inputs being registered. It's recommended to keep static names for each registered input.</li>
122
+
<li>Changing an input’s <code>name</code> on each render causes it to be re-registered as a new field.
123
+
To ensure consistent behavior, keep input names stable across renders.</li>
129
124
130
-
<li>Input value and reference will no longer gets removed based on unmount. You can invoke unregister to remove that value and reference.</li>
125
+
<li>Input values and references are not automatically removed on unmount.
126
+
Use <ahref="/docs/useform/unregister"><code>unregister</code></a> to explicitly remove them when needed.</li>
131
127
132
128
<li>
133
129
Individual register option can't be removed by `undefined` or `{}`. You can update individual attribute instead.
0 commit comments