import * as React from 'react'; import { createRoot } from 'react-dom/client'; import { useForm } from '@tanstack/react-form'; import { z } from 'zod'; import { FieldError } from './field-error'; import './index.css'; interface Role { external: External; name: string; } interface Person { name: string; age: number; roles: Role[]; } enum External { True = 'true', False = 'false', } const defaultPerson: Person = { name: 'John Doe', age: 30, roles: [ { name: 'Admin', external: External.False }, { name: 'User', external: External.False }, ], }; const roles: Role[] = [ { name: 'Admin', external: External.False }, { name: 'User', external: External.False }, ]; function App() { const form = useForm({ defaultValues: defaultPerson, onSubmit({ value }) { alert(JSON.stringify(value)); }, }); return (
{JSON.stringify(values, null, 4)}
>
)}