Skip to content

Commit 6951870

Browse files
committed
update create form control example
1 parent 58de8fd commit 6951870

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/content/docs/createFormControl.mdx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ This function create the entire form state subscription and allow you to subscri
5050
<TabGroup buttonLabels={["Setup", "Subscribe"]}>
5151

5252
```javascript
53-
const { formControl, control } = createFormControl({
53+
const { formControl, control, handleSubmit, register } = createFormControl({
5454
mode: 'onChange',
5555
defaultValues: {
5656
firstName: 'Bill'
5757
}
5858
}})
5959

6060
function App() {
61-
const { register, handleSubmit } = useForm({
61+
useForm({
6262
formControl,
6363
})
6464

@@ -85,14 +85,21 @@ function Controller() {
8585
```
8686

8787
```javascript
88-
const { formControl } = createFormControl(props)
88+
const { formControl, register } = createFormControl(props)
8989

9090
formControl.subscribe({
91-
formState: { isDirty: true },
91+
formState: {
92+
isDirty: true,
93+
values: true
94+
},
9295
callback: (formState) => {
9396
if (formState.isDirty) {
9497
// do something here
9598
}
99+
100+
if (formState.values.test.length > 3) {
101+
// do something here
102+
}
96103
},
97104
})
98105

@@ -101,7 +108,11 @@ function App() {
101108
formControl,
102109
})
103110

104-
return <form />
111+
return (
112+
<form>
113+
<input {...register('test')} />
114+
</form>
115+
)
105116
}
106117
```
107118

0 commit comments

Comments
 (0)