@@ -16,7 +16,7 @@ At it's most basic, `createFormHook` is a function that takes a `fieldContext` a
16
16
> This un-customized ` useAppForm ` hook is identical to ` useForm ` , but that will quickly change as we add more options to ` createFormHook ` .
17
17
18
18
``` tsx
19
- import { createFormHookContexts , createFormHook } from ' @tanstack/react -form'
19
+ import { createFormHookContexts , createFormHook } from ' @tanstack/solid -form'
20
20
21
21
// export useFieldContext for use in your custom components
22
22
export const { fieldContext, formContext, useFieldContext } =
@@ -31,13 +31,13 @@ const { useAppForm } = createFormHook({
31
31
})
32
32
33
33
function App() {
34
- const form = useAppForm ({
34
+ const form = useAppForm (() => ( {
35
35
// Supports all useForm options
36
36
defaultValues: {
37
37
firstName: ' John' ,
38
38
lastName: ' Doe' ,
39
39
},
40
- })
40
+ }))
41
41
42
42
return <form.Field /> // ...
43
43
}
@@ -86,12 +86,12 @@ And use it in your form:
86
86
87
87
``` tsx
88
88
function App() {
89
- const form = useAppForm ({
89
+ const form = useAppForm (() => ( {
90
90
defaultValues: {
91
91
firstName: ' John' ,
92
92
lastName: ' Doe' ,
93
93
},
94
- })
94
+ }))
95
95
96
96
return (
97
97
// Notice the `AppField` instead of `Field`; `AppField` provides the required context
@@ -135,12 +135,12 @@ const { useAppForm, withForm } = createFormHook({
135
135
})
136
136
137
137
function App() {
138
- const form = useAppForm ({
138
+ const form = useAppForm (() => ( {
139
139
defaultValues: {
140
140
firstName: ' John' ,
141
141
lastName: ' Doe' ,
142
142
},
143
- })
143
+ }))
144
144
145
145
return (
146
146
<form.AppForm >
@@ -199,12 +199,12 @@ const ChildForm = withForm({
199
199
})
200
200
201
201
function App() {
202
- const form = useAppForm ({
202
+ const form = useAppForm (() => ( {
203
203
defaultValues: {
204
204
firstName: ' John' ,
205
205
lastName: ' Doe' ,
206
206
},
207
- })
207
+ }))
208
208
209
209
return <ChildForm form = { form } title = { ' Testing' } />
210
210
}
@@ -214,7 +214,7 @@ function App() {
214
214
215
215
> Why a higher-order component instead of a hook?
216
216
217
- While hooks are the future of React , higher-order components are still a powerful tool for composition. In particular, the API of ` withForm ` enables us to have strong type-safety without requiring users to pass generics.
217
+ While hooks are the future of Solid , higher-order components are still a powerful tool for composition. In particular, the API of ` withForm ` enables us to have strong type-safety without requiring users to pass generics.
218
218
219
219
## Tree-shaking form and field components
220
220
@@ -253,7 +253,7 @@ export default function TextField(props: { label: string }) {
253
253
``` tsx
254
254
// src/hooks/form.ts
255
255
import { lazy } from ' solid-js'
256
- import { createFormHook } from ' @tanstack/react -form'
256
+ import { createFormHook } from ' @tanstack/solid -form'
257
257
258
258
const TextField = lazy (() => import (' ../components/text-fields.tsx' ))
259
259
0 commit comments