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

form.tsx

29 lines778 Bytes

1import { createFormHook, getFormHookHelpers } from '@tanstack/solid-form'
2import { TextField } from '../components/text-fields'
3​
4const { fieldComponent } = getFormHookHelpers()
5const AppTextField = fieldComponent.strict(TextField, 'field')
6​
7function SubscribeButton(props: { label: string }) {
8 const form = useFormContext()
9 return (
10 <form.Subscribe selector={(state) => state.isSubmitting}>
11 {(isSubmitting) => (
12 <button type="submit" disabled={isSubmitting()}>
13 {props.label}
14 </button>
15 )}
16 </form.Subscribe>
17 )
19​
20const { appFormOptions, useAppForm, useFormContext } = createFormHook({
21 fieldComponents: {
22 TextField: AppTextField,
23 },
24 formComponents: {
25 SubscribeButton,
26 },
27})
28​
29export { appFormOptions, useAppForm }