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

page.tsx

22 lines666 Bytes

1import { useState } from 'react'
2import { useAppForm } from '../../hooks/form.tsx'
3import { wizardFormOpts } from './shared-form.tsx'
4import { Step2Form } from './step2-subform.tsx'
5import { Step1Form } from './step1-subform.tsx'
6​
7export const WizardPage = () => {
8 const [step, setStep] = useState(0)
9 const form = useAppForm({
10 ...wizardFormOpts,
11 onSubmit: ({ value }) => {
12 alert(`Form submitted: ${JSON.stringify(value)}`)
13 },
14 })
15​
16 return (
17 <form.AppForm>
18 {step === 0 && <Step1Form form={form} step={step} setStep={setStep} />}
19 {step === 1 && <Step2Form form={form} step={step} setStep={setStep} />}
20 </form.AppForm>
21 )