diff --git a/src/stories/myForm.tsx b/src/stories/myForm.tsx index 2c0e529..9f50e47 100644 --- a/src/stories/myForm.tsx +++ b/src/stories/myForm.tsx @@ -1,14 +1,22 @@ -import React from "react"; import { useForm } from "@tanstack/react-form"; -export function MyForm() { +interface MyFormProps { + onSubmit?: (values: { + username?: string; + age?: string; + password?: string; + }) => void; +} +export function MyForm({ onSubmit }: MyFormProps) { const form = useForm({ defaultValues: { username: "", age: "", password: "", }, + onSubmit: async ({ value }) => { + onSubmit?.(value); console.log("Form submitted successfully:", value); alert(JSON.stringify(value, null, 2)); },