MCPcopy Index your code
hub / github.com/TanStack/form / MainComponent

Function MainComponent

examples/react/ui-libraries/src/MainComponent.tsx:8–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import { Checkbox as MuiCheckbox } from '@mui/material'
7
8export default function MainComponent() {
9 const form = useForm({
10 defaultValues: {
11 firstName: '',
12 lastName: '',
13 isChecked: false,
14 isMuiCheckBox: false,
15 },
16 onSubmit: async ({ value }) => {
17 // Do something with form data
18 console.log(value)
19 },
20 })
21
22 return (
23 <MantineProvider>
24 <form
25 onSubmit={(e) => {
26 e.preventDefault()
27 e.stopPropagation()
28 form.handleSubmit()
29 }}
30 >
31 <form.Field
32 name="firstName"
33 children={({ state, handleChange, handleBlur }) => {
34 return (
35 <TextInput
36 defaultValue={state.value}
37 onChange={(e) => handleChange(e.target.value)}
38 onBlur={handleBlur}
39 placeholder="Enter your name"
40 />
41 )
42 }}
43 />
44 <form.Field
45 name="lastName"
46 children={({ state, handleChange, handleBlur }) => {
47 return (
48 <TextField
49 id="filled-basic"
50 label="Filled"
51 variant="filled"
52 defaultValue={state.value}
53 onChange={(e) => handleChange(e.target.value)}
54 onBlur={handleBlur}
55 placeholder="Enter your last name"
56 />
57 )
58 }}
59 />
60 <form.Field
61 name="isChecked"
62 children={({ state, handleChange, handleBlur }) => {
63 return (
64 <Checkbox
65 onChange={(e) => handleChange(e.target.checked)}

Callers

nothing calls this directly

Calls 2

useFormFunction · 0.90
handleSubmitMethod · 0.65

Tested by

no test coverage detected