refactor(MyForm): add onSubmit prop for Storybook actions integration
This commit is contained in:
+10
-2
@@ -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));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user