Skip to content

Commit 117b743

Browse files
authored
docs(solid-form): update examples from react to solid. (#1607)
1 parent 5c7524d commit 117b743

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/framework/solid/guides/form-composition.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ At it's most basic, `createFormHook` is a function that takes a `fieldContext` a
1616
> This un-customized `useAppForm` hook is identical to `useForm`, but that will quickly change as we add more options to `createFormHook`.
1717
1818
```tsx
19-
import { createFormHookContexts, createFormHook } from '@tanstack/react-form'
19+
import { createFormHookContexts, createFormHook } from '@tanstack/solid-form'
2020

2121
// export useFieldContext for use in your custom components
2222
export const { fieldContext, formContext, useFieldContext } =
@@ -31,13 +31,13 @@ const { useAppForm } = createFormHook({
3131
})
3232

3333
function App() {
34-
const form = useAppForm({
34+
const form = useAppForm(() => ({
3535
// Supports all useForm options
3636
defaultValues: {
3737
firstName: 'John',
3838
lastName: 'Doe',
3939
},
40-
})
40+
}))
4141

4242
return <form.Field /> // ...
4343
}
@@ -86,12 +86,12 @@ And use it in your form:
8686

8787
```tsx
8888
function App() {
89-
const form = useAppForm({
89+
const form = useAppForm(() => ({
9090
defaultValues: {
9191
firstName: 'John',
9292
lastName: 'Doe',
9393
},
94-
})
94+
}))
9595

9696
return (
9797
// Notice the `AppField` instead of `Field`; `AppField` provides the required context
@@ -135,12 +135,12 @@ const { useAppForm, withForm } = createFormHook({
135135
})
136136

137137
function App() {
138-
const form = useAppForm({
138+
const form = useAppForm(() => ({
139139
defaultValues: {
140140
firstName: 'John',
141141
lastName: 'Doe',
142142
},
143-
})
143+
}))
144144

145145
return (
146146
<form.AppForm>
@@ -199,12 +199,12 @@ const ChildForm = withForm({
199199
})
200200

201201
function App() {
202-
const form = useAppForm({
202+
const form = useAppForm(() => ({
203203
defaultValues: {
204204
firstName: 'John',
205205
lastName: 'Doe',
206206
},
207-
})
207+
}))
208208

209209
return <ChildForm form={form} title={'Testing'} />
210210
}
@@ -214,7 +214,7 @@ function App() {
214214

215215
> Why a higher-order component instead of a hook?
216216
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.
218218

219219
## Tree-shaking form and field components
220220

@@ -253,7 +253,7 @@ export default function TextField(props: { label: string }) {
253253
```tsx
254254
// src/hooks/form.ts
255255
import { lazy } from 'solid-js'
256-
import { createFormHook } from '@tanstack/react-form'
256+
import { createFormHook } from '@tanstack/solid-form'
257257

258258
const TextField = lazy(() => import('../components/text-fields.tsx'))
259259

0 commit comments

Comments
 (0)