You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: improve get started guide for React to be more representative (#1214)
* docs: improve get started guide for React to be more representative
* docs: revise with feedback from @phryneas
* docs: minor additions
---------
Co-authored-by: Leonardo Montini <lion.48m@gmail.com>
The bare minimum to get started with TanStack Form is to create a form and add a field. Keep in mind that this example does not include any validation or error handling... yet.
6
+
TanStack Form is unlike most form libraries you've used before. It's designed for large-scale production usage, with a focus on type safety, performance and composition for an unmatched developer experience.
7
+
8
+
As a result, we've developed [a philosophy around the library's usage](/form/latest/docs/philosophy) that values scalability and long-term developer experience over short and sharable code snippets.
9
+
10
+
Here's an example of a form following many of our best practices, which will allow you to rapidly develop even high-complexity forms after a short onboarding experience:
While we generally suggest using `createFormHook` for reduced boilerplate in the long-run, we also support one-off components and other behaviors using `useForm` and `form.Field`:
88
+
89
+
```tsx
90
+
importReactfrom'react'
91
+
importReactDOMfrom'react-dom/client'
92
+
import { useForm } from'@tanstack/react-form'
93
+
94
+
const PeoplePage = () => {
95
+
const form =useForm({
96
+
defaultValues: {
97
+
username: '',
98
+
age: 0
99
+
},
100
+
onSubmit: ({ value }) => {
101
+
// Do something with form data
102
+
alert(JSON.stringify(value, null, 2));
103
+
},
104
+
});
105
+
106
+
return (
107
+
<form.Field
108
+
name="age"
109
+
validators={{
110
+
// We can choose between form-wide and field-specific validators
0 commit comments