Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

form.tsx

27 lines719 Bytes

1import { createFormHook } from '@tanstack/solid-form'
2import { lazy } from 'solid-js'
3import { fieldContext, formContext, useFormContext } from './form-context.tsx'
4​
5const TextField = lazy(() => import('../components/text-fields.tsx'))
6​
7function SubscribeButton(props: { label: string }) {
8 const form = useFormContext()
9 return (
10 <form.Subscribe selector={(state) => state.isSubmitting}>
11 {(isSubmitting) => (
12 <button disabled={isSubmitting()}>{props.label}</button>
13 )}
14 </form.Subscribe>
15 )
17​
18export const { useAppForm, withForm, withFieldGroup } = createFormHook({
19 fieldComponents: {
20 TextField,
21 },
22 formComponents: {
23 SubscribeButton,
24 },
25 fieldContext,
26 formContext,
27})