Skip to content

Commit 4f60628

Browse files
committed
update register
1 parent 5b95f80 commit 4f60628

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/content/docs/useform/register.mdx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,32 +102,28 @@ By selecting the register option, the API table below will get updated.
102102

103103
<ul>
104104
<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).
108107
</li>
109108
<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+
117112
```javascript
118-
register('test.0.firstName'); //
119-
register('test[0]firstName'); //
113+
register('test.0.firstName'); //
114+
register('test[0].firstName'); //
120115
```
121-
122116
</li>
123117

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>
127121

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>
129124

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 <a href="/docs/useform/unregister"><code>unregister</code></a> to explicitly remove them when needed.</li>
131127

132128
<li>
133129
Individual register option can't be removed by `undefined` or `{}`. You can update individual attribute instead.

0 commit comments

Comments
 (0)